public JsonResult Action(CourseActionModel model) { var result = false; JsonResult json = new JsonResult(); if (model.ID > 0) // We try to edit record { var course = CourseService.Instance.GetCoursesById(model.ID); course.Name = model.Name; course.Description = model.Description; result = CourseService.Instance.UpdateCourses(course); } else // We try to create record { Course course = new Course(); course.Name = model.Name; course.Description = model.Description; result = CourseService.Instance.SaveCourses(course); } if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to Perform action on Course" }; } return(json); }
public ActionResult Delete(int ID) { CourseActionModel model = new CourseActionModel(); var course = CourseService.Instance.GetCoursesById(ID); model.ID = course.ID; return(PartialView("_Delete", model)); }
public ActionResult Delete(int ID) { Course course = service.GetByID(ID); CourseActionModel model = new CourseActionModel { ID = course.ID, Title = course.Title }; return(PartialView("_Delete", model)); }
public ActionResult Action(int?ID) { CourseActionModel model = new CourseActionModel(); if (ID.HasValue) { Course course = service.GetByID(ID.Value); model.ID = course.ID; model.Title = course.Title; model.Duration = course.Duration; model.Fee = course.Fee; model.CoursePictures = course.CoursePictures; } return(PartialView("_Action", model)); }
public ActionResult Action(int?ID) { CourseActionModel model = new CourseActionModel(); if (ID.HasValue)//we are trying to edit record { var course = CourseService.Instance.GetCoursesById(ID.Value); model.ID = course.ID; model.Name = course.Name; model.Description = course.Description; } //else no need //{ //} return(PartialView("_Action", model)); }
public JsonResult Delete(CourseActionModel model) { var result = false; JsonResult json = new JsonResult(); var course = CourseService.Instance.GetCoursesById(model.ID); result = CourseService.Instance.DeleteCourses(course); if (result) { json.Data = new { Success = true }; } else { json.Data = new { Success = false, Message = "Unable to Perform action on Course." }; } return(json); }
public ActionResult Delete(CourseActionModel model) { string msg = ""; VoucherType objectData = service.GetByID(model.ID); bool result; try { result = service.Delete(objectData); } catch (Exception exc) { msg = exc.Message.ToString(); result = false; } JsonResult jsonResult = new JsonResult { Data = result ? (new { Success = true, Msg = msg }) : (new { Success = false, Msg = msg }), }; return(jsonResult); }
public JsonResult Action(CourseActionModel model) { bool result; Course objectFirst; string msg = ""; if (model.ID > 0) { objectFirst = service.GetByID(model.ID); objectFirst.Title = model.Title; objectFirst.Duration = model.Duration; objectFirst.Fee = model.Fee; objectFirst.UserID = UserHelperInfo.GetUserId(); objectFirst.ModifiedOn = DateTime.Now; objectFirst.IP = UserInfo.IP(); objectFirst.Agent = UserInfo.Agent(); objectFirst.Location = UserInfo.Location(); try { objectFirst.CoursePictures.Clear(); List <int> PictureListIDs = (!string.IsNullOrEmpty(model.PictureIDs) ? model.PictureIDs.Split(',').Select(x => int.Parse(x)).ToList() : new List <int>()); var pictures = dashboardService.GetPictures(PictureListIDs); objectFirst.CoursePictures = new List <CoursePicture>(); objectFirst.CoursePictures.AddRange(pictures.Select(x => new CoursePicture() { CourseID = model.ID, PictureID = x.ID })); result = service.Update(objectFirst); } catch (Exception exc) { msg = exc.Message.ToString(); result = false; } } else { objectFirst = new Course { Title = model.Title, Duration = model.Duration, Fee = model.Fee, ModifiedOn = DateTime.Now, UserID = UserHelperInfo.GetUserId(), IP = UserInfo.IP(), Agent = UserInfo.Agent(), Location = UserInfo.Location(), }; try { List <int> PictureListIDs = (!string.IsNullOrEmpty(model.PictureIDs) ? model.PictureIDs.Split(',').Select(x => int.Parse(x)).ToList() : new List <int>()); var pictures = dashboardService.GetPictures(PictureListIDs); objectFirst.CoursePictures = new List <CoursePicture>(); objectFirst.CoursePictures.AddRange(pictures.Select(x => new CoursePicture() { PictureID = x.ID })); result = service.Save(objectFirst); } catch (Exception exc) { msg = exc.Message.ToString(); result = false; } } JsonResult jsonResult = new JsonResult { Data = result ? (new { Success = true, Msg = msg }) : (new { Success = false, Msg = msg }) }; return(jsonResult); }