NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Write a note in this area. It's really easy to share withusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Mvc;
using System.Xml;
using System.Collections;
using Step2GenMVC_Task_1.Models;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Web.Configuration;
using Step2GenMVC_Task_1.ViewModal;

namespace Step2GenMVC_Task_1.Controllers
{
public class LoginController : Controller
{

public static List<UserModel> listOfUsers;
static LoginController()
{

}

// GET: Login
[Route("login")]
[HttpPost]
public ActionResult Index(LoginDataModel obj)
{
string email = obj.UserName;
string password = obj.Password;
if (String.IsNullOrWhiteSpace(email) || String.IsNullOrWhiteSpace(password))
return Content("-1");
else
{
// Here we have non empty data and password
string path = Server.MapPath(WebConfigurationManager.AppSettings.Get("credentialsFile"));
StreamReader reader;
List<UserCredentialDataModel> listOfUsers;
UserCredentialsDataModel usersModel;
XmlSerializer deserialiser = new XmlSerializer(typeof(UserCredentialsDataModel));
reader = new StreamReader(path);
usersModel = (UserCredentialsDataModel)deserialiser.Deserialize(reader);
reader.Close();
listOfUsers = usersModel.User;
foreach(UserCredentialDataModel user in listOfUsers)
if (email == user.Email && password == user.Password)
{
//return Content(listOfUsers.Count.ToString());
return Content("Welcome/"+email);
//return RedirectToAction("Welcome");
}
}
return Content("-1");
}

[Route("welcome/{email}")]
public ActionResult Welcome(string email)
{
UserDataViewModel user = new UserDataViewModel() { Email = email };
return View(user);
//return RedirectToAction("json");
}

[Route("json")]
public ActionResult JsonObject()
{
// Newer Code
string path = Server.MapPath(WebConfigurationManager.AppSettings.Get("usersDataFile"));
StreamReader reader;
List<UserModel> listOfUsers;
List<UserModel> listOfUsersToBeSent = new List<UserModel>();
UsersModel usersModel;
XmlSerializer deserialiser = new XmlSerializer(typeof(UsersModel));
reader = new StreamReader(path);
usersModel = (UsersModel)deserialiser.Deserialize(reader);
reader.Close();
listOfUsers = usersModel.User;
LoginController.listOfUsers = usersModel.User;
// to filter the user with name starting with "A"
var query = from user in listOfUsers
where user.Name.StartsWith("A")
select user;
foreach(UserModel u in query)
{
listOfUsersToBeSent.Add(u);
}
return Json(listOfUsers, JsonRequestBehavior.AllowGet);
//return Json(listOfUsersToBeSent, JsonRequestBehavior.AllowGet);
//return Content("Json method");
}

[Route("innerJoin")]
public ActionResult JoinDemo()
{
string path = Server.MapPath(WebConfigurationManager.AppSettings.Get("cityDataFile"));
StreamReader reader;
List<UserModel> listOfUsers = LoginController.listOfUsers;
//return Content(listOfUsers.Count.ToString());
List<CityModel> listOfCities;
CitiesModel citiesModel;
XmlSerializer deserialiser = new XmlSerializer(typeof(CitiesModel));
reader = new StreamReader(path);
citiesModel = (CitiesModel)deserialiser.Deserialize(reader);
reader.Close();
listOfCities = citiesModel.City;
List<UserCityViewModel> userCityViews = new List<UserCityViewModel>();
var query = from user in listOfUsers
join city in listOfCities
on user.City equals city.Name
select new UserCityViewModel{Name = user.Name,Gender =user.Gender, Age = user.Age.ToString(),Email = user.Email,City = user.City,Pincode = city.Pincode};
foreach(var user in query)
{
userCityViews.Add(user);
}
//return Json(listOfCities,JsonRequestBehavior.AllowGet);
//return Content(LoginController.listOfUsers.Count.ToString() + " - " + listOfCities.Count.ToString());
return Json(userCityViews,JsonRequestBehavior.AllowGet);

}
}
} others. Click here ...
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.