public SpecialtyViewModel(Specialty specialty) : this() { Id = specialty.Id; Name = specialty.Name; Description = specialty.Description; Major = new MajorViewModel(specialty.Major); StandardOfCertificate = new StandardOfCertificateViewModel(specialty.StandardOfCertificate); }
private void CopyToMajor(MajorViewModel majorViewModel, Major major) { major.Id = majorViewModel.Id; major.Subject = majorViewModel.Subject; major.Status = majorViewModel.Status; major.YearOfGraduate = majorViewModel.YearOfGraduate; major.UserId = majorViewModel.UserId; }
private List <string> GetAllPropertyNameOfMajorViewModel() { var majorViewModel = new MajorViewModel(); var type = majorViewModel.GetType(); return(ReflectionUtilities.GetAllPropertyNamesOfType(type)); }
public ActionResult Create(MajorViewModel majorViewModel) { if (ModelState.IsValid) { Save(majorViewModel); return(RedirectToAction("Index", new { UserId = majorViewModel.UserId })); } return(View()); }
private void UpdateMajor(MajorViewModel majorViewModel) { var dbContext = new AppDbContext(); var major = dbContext.Majors.Find(majorViewModel.Id); CopyToMajor(majorViewModel, major); dbContext.SaveChanges(); }
private void Save(MajorViewModel majorViewModel) { var dbContext = new AppDbContext(); var major = MapToMajor(majorViewModel); dbContext.Majors.Add(major); dbContext.SaveChanges(); }
public ActionResult MajorDetail(int?id) { MajorViewModel model = new MajorViewModel(); if (id.HasValue) { model = new MajorRepository().GetByID((int)id); } return(PartialView("_Major", model)); }
public ActionResult Edit(MajorViewModel majorViewModel) { if (ModelState.IsValid) { UpdateMajor(majorViewModel); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Index() { var majors = await _majorService.GetAllAsync(); var viewModel = new MajorViewModel { Majors = majors }; return(View(viewModel)); }
private Major MapToMajor(MajorViewModel majorViewModel) { return(new Major { Id = majorViewModel.Id, Status = majorViewModel.Status, Subject = majorViewModel.Subject, UserId = majorViewModel.UserId, YearOfGraduate = majorViewModel.YearOfGraduate }); }
public ActionResult UpdateMajor(MajorViewModel major) { if (ModelState.IsValid) { var mjor = new Major(); major.updateMajor(mjor); db.Entry(mjor).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MajorsList")); } return(View()); }
public ActionResult CreateMajor(MajorViewModel major) { if (ModelState.IsValid) { var newmajor = new Major(); major.updateMajor(newmajor); db.Majors.Add(newmajor); db.SaveChanges(); return(RedirectToAction("MajorsList")); } return(View()); }
public JsonResult SaveMajor(MajorViewModel model) { ResponseData result = new Models.ResponseData(); if (model.MajID != 0) { result = new MajorRepository().UpdateByEntity(model); } else { result = new MajorRepository().AddByEntity(model); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult MajorsUpdate([DataSourceRequest]DataSourceRequest request, MajorViewModel major) { var majorExists = this.majors.All().Any(m => m.Name == major.Name); if (majorExists) { this.ModelState.AddModelError("Major exists", "Major will such name already exists."); } if (this.ModelState.IsValid) { var entity = this.Mapper.Map<Major>(major); this.majors.Update(entity); } return this.Json(new[] { major }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult GetAMajor(int?id) { MajorViewModel _majorViewModel = new MajorViewModel(); if (id == null) { _majorViewModel.DepartmentsList = new SelectList(db.Departments, "DepartmentID", "DepartmentName"); return(PartialView("_Modal.FormContent", _majorViewModel)); } Major major = db.Majors.Find(id); _majorViewModel.MajorID = major.MajorID; _majorViewModel.MajorName = major.MajorName; _majorViewModel.DepartmentsList = new SelectList(db.Departments, "DepartmentID", "DepartmentName", major.DepartmentID); return(PartialView("_Modal.FormContent", _majorViewModel)); }
public ResponseData UpdateByEntity(MajorViewModel newdata) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { var data = db.tb_Major.Single(x => x.MajID == newdata.MajID); data.MajName = newdata.MajName; data.MajStatus = (newdata.Status == "1") ? true : false; data.ModifyBy = UtilityService.User.UserID; data.ModifyDate = DateTime.Now; db.SaveChanges(); } catch (Exception) { } return(result); } }
public ActionResult UpdateMajor(int?id) { if (id == null) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } Major mj = db.Majors.Find(id); if (mj == null) { return(HttpNotFound()); } MajorViewModel major = new MajorViewModel(mj.id, mj.facultyId, mj.name, mj.isInactive); ViewBag.facultyList = new SelectList( db.Faculties.Select(x => new { Text = x.name, Value = x.id }), "Value", "Text", mj.facultyId); return(View(major)); }
public ActionResult MajorsCreate([DataSourceRequest]DataSourceRequest request, MajorViewModel major) { var majorExists = this.majors.All().Any(m => m.Name == major.Name); if (majorExists) { this.ModelState.AddModelError("Major exists", "Major with such name already exists."); } Major result = null; if (this.ModelState.IsValid) { result = this.majors.Create(major.Name); } if (result != null) { return this.Json(new[] { result }.ToDataSourceResult(request, this.ModelState)); } return this.Json(new[] { major }.ToDataSourceResult(request, this.ModelState)); }
public ResponseData AddByEntity(MajorViewModel data) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { tb_Major model = new tb_Major(); model.MajID = data.MajID; model.MajName = data.MajName; model.MajStatus = (data.Status == "1") ? true : false; model.CreateBy = UtilityService.User.UserID; model.CreateDate = DateTime.Now; model.ModifyBy = UtilityService.User.UserID; model.ModifyDate = DateTime.Now; db.tb_Major.Add(model); db.SaveChanges(); } catch (Exception) { } return(result); } }
public bool Edit(MajorViewModel majorViewModel) { return(_repository.Edit(MapToMajor(majorViewModel))); }
public bool Create(MajorViewModel majorViewModel) { return(_repository.Create(MapToMajor(majorViewModel))); }
public ActionResult MajorsDestroy([DataSourceRequest]DataSourceRequest request, MajorViewModel major) { this.majors.Delete(major.Id); return this.Json(new[] { major }.ToDataSourceResult(request, this.ModelState)); }