public override AddressModel GetById(int id) { using (DemoEntities db = new DemoEntities()) { return(db.Addresses.Find(id)); } }
public ActionResult Follow(string id, string followid) { DemoEntities demo = new DemoEntities(); int? rowCount = demo.FollowUser(Convert.ToInt32(id), followid).FirstOrDefault(); return(SearchIndex(id)); }
public IEnumerable <Product> Get() { using (DemoEntities demo = new DemoEntities()) { return(demo.Products.ToList()); } }
public JsonResult EmpLogin(string EmpName, string Password) { try { AppLib.WriteLog("Login_Start"); var db = new DemoEntities(); var qry = from am in db.AccountMs join amp in db.AccountMPasswords on am.UID equals amp.AccountM_UID where am.AccountTypeID == 800 && am.AccountName == EmpName && amp.Password == Password select new { am.UID, am.AccountCode }; var d = qry.FirstOrDefault(); if (d == null) { var r = Json(new { IsLogin = false, ErrMsg = "Invalid User" }, JsonRequestBehavior.AllowGet); AppLib.WriteLog("Login_Failed"); return(r); } else { var r = Json(new { IsLogin = true, EmpCode = d.AccountCode, ErrMsg = "" }, JsonRequestBehavior.AllowGet); AppLib.WriteLog("Login_End"); return(r); } } catch (Exception ex) { AppLib.WriteLog(ex); var r = Json(new { IsLogin = false, ErrMsg = "Invalid User" }, JsonRequestBehavior.AllowGet); return(r); } }
public ActionResult UserList() { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } DemoEntities db = new DemoEntities(); //IEnumerable<MaidEasy.Models.user> us = db.users.ToList(); IEnumerable <MaidEasy.Models.user> userList = dbContext.users.ToList(); RegisterController regC = new RegisterController(); foreach (var item in userList) { int id = regC.getThanaID(item.thana); thana thana = dbContext.thana.Find(id); item.thana = thana.Name; System.Diagnostics.Debug.WriteLine("--------------"); System.Diagnostics.Debug.WriteLine(thana.ThanaId); System.Diagnostics.Debug.WriteLine(thana.Name); System.Diagnostics.Debug.WriteLine("--------------"); } return(View(userList)); }
public UserProfileView GetUserProfile(int userID) { UserProfileView UPV = new UserProfileView(); using (DemoEntities db = new DemoEntities()) { var user = db.SYSUsers.Find(userID); if (user != null) { UPV.SYSUserID = user.SYSUserID; UPV.LoginName = user.LoginName; UPV.Password = user.PasswordEncryptedText; var SUP = db.SYSUserProfiles.Find(userID); if (SUP != null) { UPV.FirstName = SUP.FirstName; UPV.LastName = SUP.LastName; UPV.Gender = SUP.Gender; } var SUR = db.SYSUserRoles.Find(userID); if (SUR != null) { UPV.LOOKUPRoleID = SUR.LOOKUPRoleID; UPV.RoleName = SUR.LOOKUPRole.RoleName; UPV.IsRoleActive = SUR.IsActive; } } } return(UPV); }
private void LoadCategoryList() { using (var entities = new DemoEntities()) { Categories = entities.Categories.ToList(); } }
public void CRUD_DisableProxy() { using (var db = new DemoEntities()) { db.Configuration.ProxyCreationEnabled = false; Product newProduct = new Product { ProductName = "Pepe Jeans", CategoryId = 2 }; db.Products.Add(newProduct); Product existingProduct = db.Products.Find(1); existingProduct.ProductName = "Killer"; Category existingCategory = db.Categories.Find(1); Category newCategory = new Category { CategoryName = "Jeans" }; db.Categories.Add(newCategory); Customer customer = new Customer { FullName = "Billa Timepass", Address = "Pune" }; db.Customers.Add(customer); var entries = db.ChangeTracker.Entries(); // db.SaveChanges(); } }
// GET: Access public ActionResult Index() { using (DemoEntities db = new DemoEntities()) { return(View()); } }
public Course Get(int id) { DemoEntities Entitie = new DemoEntities(); var obj = Entitie.Course.Where(z => z.id == id).FirstOrDefault(); return(obj); }
public PartialViewResult _LoginPartial() { var model = new UserInfo(); model.IsAuthenticated = HttpContext.User.Identity.IsAuthenticated; if (model.IsAuthenticated) { using (var db = new DemoEntities()) { // Hit the database and retrieve the UserProfile info var user = db.UserProfiles.Single(u => u.UserName == HttpContext.User.Identity.Name); if (user != null) { model.FirstName = user.FirstName; model.LastName = user.LastName; } } //Return populated ViewModel return(this.PartialView(model)); } //return the model with IsAuthenticated only return(this.PartialView(model)); }
public List <Course> Listar() { DemoEntities Entitie = new DemoEntities(); var lista = Entitie.Course.ToList(); return(lista); }
public override DepartmentModel GetById(int id) { using (DemoEntities db = new DemoEntities()) { return(db.Departments.Find(id)); } }
public override List <DepartmentModel> GetAll() { using (DemoEntities db = new DemoEntities()) { return(db.Departments.ToList()); } }
//Put Method public IHttpActionResult Put(Models.InformationView info) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (var ctx = new DemoEntities()) { var eInfo = ctx.InforMation.Where(s => s.Id == info.Id) .FirstOrDefault <InforMation>(); if (eInfo != null) { eInfo.Name = info.Name; ctx.SaveChanges(); } else { return(NotFound()); } } return(Ok()); }
public List <StudentCourse> listarxStudent(int idStudent) { DemoEntities Entitie = new DemoEntities(); var lista = Entitie.StudentCourse.Where(x => x.idstudent == idStudent).ToList(); return(lista); }
//Post Method public IHttpActionResult PostInformation(Models.InformationView info) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } using (var ctx = new DemoEntities()) { ctx.InforMation.Add(new InforMation() { Id = info.Id, Name = info.Name, Address = info.Address, Mobile = info.Mobile, Email = info.Email }); } // ctx.SaveChanges(); // IList<Models.InformationView> info1 = null; // info1 = ctx.InforMation.Select(s => new Models.InformationView() // { // Id = s.Id, // Name = s.Name, // Address = s.Address, // Mobile = s.Mobile, // Email = s.Email // }).ToList<Models.InformationView>(); //} return(Ok()); }
public override List <ShopModel> GetAll() { using (DemoEntities db = new DemoEntities()) { return(db.Shops.ToList()); } }
public bool IsLoginNameExist(string loginName) { using (DemoEntities db = new DemoEntities()) { return(db.SYSUsers.Where(o => o.LoginName.Equals(loginName)).Any()); } }
public override ShopModel GetById(int id) { using (DemoEntities db = new DemoEntities()) { return(db.Shops.Find(id)); } }
public ActionResult CustomerStatus(decimal UID) { var db = new DemoEntities(); var cust = db.ViewCustomerDetails.Where(x => x.UID == UID).FirstOrDefault(); return(View(cust)); }
public object updateRecord(UpdateGenericFormModel form) { DateTime today = DateTime.Today; try { using (DemoEntities db = new DemoEntities()) { // Read the form data. GenericTable updateRecordForm = db.GenericTables.Find(form.Id); updateRecordForm.Text = form.Text; updateRecordForm.Number = int.Parse(form.Number); updateRecordForm.Boolean = Boolean.Parse(form.Boolean); updateRecordForm.JSDate = DateTime.Parse(form.JSDate); updateRecordForm.JSDateTime = today; db.SaveChanges(); return(new { status = StatusCodes.OK.code, msg = "Successfully Updated Record" }); } } catch (System.Exception e) { return(new { status = StatusCodes.NotFound.code, msg = e.InnerException, data = 0 }); } }
public IHttpActionResult EditStudent(Sinh_Vien student) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (var ctx = new DemoEntities()) { var existingStudent = ctx.Sinh_Vien.Where(s => s.MSV == student.MSV) .FirstOrDefault <Sinh_Vien>(); if (existingStudent != null) { existingStudent.Ho = student.Ho; existingStudent.Ten = student.Ten; ctx.SaveChanges(); } else { return(NotFound()); } } return(Ok()); }
public object addRecord(GenericFormModel form) { DateTime today = DateTime.Today; try { using (DemoEntities db = new DemoEntities()) { // Read the form data. GenericTable addRecordForm = new GenericTable(); addRecordForm.Text = form.Text; addRecordForm.Number = int.Parse(form.Number); addRecordForm.Boolean = Boolean.Parse(form.Boolean); addRecordForm.JSDate = DateTime.Parse(form.JSDate); //addRecordForm.JSDateTime = DateTime.Parse(form.JSDateTime); db.GenericTables.Add(addRecordForm); db.SaveChanges(); return(new { status = StatusCodes.OK.code, msg = "Successfully Added Record To Database" }); } } catch (System.Exception e) { return(new { status = StatusCodes.NotFound.code, msg = e.InnerException, data = 0 }); } }
public ActionResult SearchIndex(string id) { DemoEntities demo = new DemoEntities(); TblTweetuser user = demo.GetUserByUserId(id).FirstOrDefault(); string message = string.Empty; Tweets tuser = new Tweets(); ObjectResult <TblTweet> list = demo.DisplayTweets("%" + user.UserId.ToString() + "%"); List <TblTweet> result = list.Select(x => new TblTweet { TweetId = x.TweetId, TweetUserId = x.TweetUserId, TweetUserName = x.TweetUserName, TweetDeleted = x.TweetDeleted, TweetModifiedDate = x.TweetModifiedDate, TweetText = x.TweetText, }).ToList(); tuser.tweetslists = result; tuser.UserName = user.UserName; tuser.UserId = user.UserId.ToString(); ViewBag.UserName = user.UserName; ViewBag.UserId = user.UserId.ToString(); return(View("Home", tuser)); }
private void LoadGenderList() { using (var entities = new DemoEntities()) { Genders = entities.Genders.ToList(); } }
public ActionResult Register(TblTweetuser user) { DemoEntities demo = new DemoEntities(); demo.TblTweetusers.Add(user); demo.SaveChanges(); string message = string.Empty; switch (user.UserId) { case -1: message = "Username already exists.\\nPlease choose a different username."; break; case -2: message = "Supplied email address has already been used."; break; default: message = "Registration successful.\\nUser Id: " + user.UserId.ToString(); break; } ViewBag.Message = message; // usersEntities.dis ObjectResult <TblTweet> list = demo.DisplayTweets("%," + user.UserId.ToString() + ",%"); Tweets tuser = TweetLists(user.UserId.ToString(), user.UserName, list); ViewBag.UserName = user.UserName; ViewBag.UserId = user.UserId.ToString(); return(View("Home", tuser)); }
private void UpdateCustomer(GridViewRow row) { var txtTitle = row.FindControl("txtTitle") as TextBox; var txtFirstName = row.FindControl("txtFirstName") as TextBox; var txtLastName = row.FindControl("txtLastName") as TextBox; var txtDateOfBirth = row.FindControl("txtDateOfBirth") as TextBox; var ddlGender = row.FindControl("ddlGender") as DropDownList; var id = int.Parse(gridViewCustomers.DataKeys[row.RowIndex].Value.ToString()); var customer = Customers.FirstOrDefault(x => x.Id == id); if (customer == null) { ValidationMessages.Add("Unable to locate customer record to update"); return; } using (var entities = new DemoEntities()) { entities.Customers.Attach(customer); customer.Title = txtTitle.Text; customer.FirstName = txtFirstName.Text; customer.LastName = txtLastName.Text; customer.DateOfBirth = DateTime.Parse(txtDateOfBirth.Text); customer.GenderId = int.Parse(ddlGender.SelectedValue); entities.SaveChanges(); } }
public override List <AddressModel> GetAll() { using (DemoEntities db = new DemoEntities()) { return(db.Addresses.ToList()); } }
private void GenerateReport(DateTime fromDate, DateTime toDate) { using (var entities = new DemoEntities()) { var reportData = entities.DemographicRevenue(fromDate, toDate).ToList(); DisplayReportData(reportData); } }