public static ResponseResult Delete(BootcampTypeViewModel entity) { ResponseResult result = new ResponseResult(); using (var db = new XBC_Context()) { t_bootcamp_type botp = db.t_bootcamp_type.Where(o => o.id == entity.id).FirstOrDefault(); if (botp != null) { var json = new JavaScriptSerializer().Serialize(botp); t_audit_log log = new t_audit_log(); log.type = "Modify"; log.json_before = json; log.created_by = entity.UserId; log.created_on = DateTime.Now; botp.is_delete = true; botp.deleted_by = entity.UserId; botp.deleted_on = DateTime.Now; var json2 = new JavaScriptSerializer().Serialize(botp); log.json_after = json2; db.t_audit_log.Add(log); db.SaveChanges(); result.Entity = entity; } else { result.Success = false; result.ErrorMessage = "Bootcamp Type not found!"; } } return(result); }
public ActionResult Delete(BootcampTypeViewModel model) { ResponResultViewModel result = BootcampTypeRepo.Delete(model.id); return(Json(new { success = result.Success, message = result.Message, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(BootcampTypeViewModel model) { ResponseResult result = BootcampTypeRepo.Update(model); return(Json(new { success = result.Success, message = result.ErrorMessage, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
public static ResponResultViewModel Update(BootcampTypeViewModel entity) { ResponResultViewModel result = new ResponResultViewModel(); try { using (var db = new MinProContext()) { if (entity.id == 0) { t_bootcamp_type bt = new t_bootcamp_type(); bt.name = entity.name; bt.notes = entity.notes; bt.created_by = 1; bt.created_on = DateTime.Now; bt.active = true; db.t_bootcamp_type.Add(bt); db.SaveChanges(); result.Entity = entity; } else { if (entity != null) { t_bootcamp_type bt = db.t_bootcamp_type.Where(o => o.id == entity.id).FirstOrDefault(); bt.name = entity.name; bt.notes = entity.notes; bt.modified_by = 1; bt.modified_on = DateTime.Now; bt.active = true; db.SaveChanges(); result.Entity = entity; } else { result.Success = false; result.Message = "Bootcamp Type Not Found"; } } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public static BootcampTypeViewModel GetId(long id) { BootcampTypeViewModel result = new BootcampTypeViewModel(); using (var db = new MinProContext()) { result = (from bt in db.t_bootcamp_type where bt.id == id select new BootcampTypeViewModel { id = bt.id, name = bt.name, notes = bt.notes, created_by = bt.created_by, created_on = bt.created_on, active = bt.active }).FirstOrDefault(); if (result == null) { result = new BootcampTypeViewModel(); } } return(result); }
public static BootcampTypeViewModel ById(long id) { BootcampTypeViewModel result = new BootcampTypeViewModel(); using (var db = new XBC_Context()) { result = (from botp in db.t_bootcamp_type join us in db.t_user on botp.created_by equals us.id where botp.id == id && botp.is_delete == false select new BootcampTypeViewModel { id = botp.id, name = botp.name, notes = botp.notes, createdBy = botp.created_by, CreatedByName = us.username }).FirstOrDefault(); if (result == null) { result = new BootcampTypeViewModel(); } } return(result); }
public static ResponseResult Update(BootcampTypeViewModel entity) { ResponseResult result = new ResponseResult(); using (var db = new XBC_Context()) { if (entity.id == 0) { t_bootcamp_type botp = new t_bootcamp_type(); botp.name = entity.name; botp.notes = entity.notes; botp.created_by = 01; botp.created_on = DateTime.Now; botp.is_delete = false; db.t_bootcamp_type.Add(botp); db.SaveChanges(); var json = new JavaScriptSerializer().Serialize(botp); t_audit_log log = new t_audit_log(); log.type = "Insert"; log.json_insert = json; log.created_by = entity.UserId; log.created_on = DateTime.Now; db.t_audit_log.Add(log); db.SaveChanges(); entity.id = botp.id; result.Entity = entity; } else //edit { t_bootcamp_type botp = db.t_bootcamp_type.Where(btp => btp.id == entity.id).FirstOrDefault(); if (botp != null) { var json = new JavaScriptSerializer().Serialize(botp); t_audit_log log = new t_audit_log(); log.type = "Modify"; log.json_before = json; log.created_by = entity.UserId; log.created_on = DateTime.Now; botp.name = entity.name; botp.notes = entity.notes; botp.modified_by = entity.UserId; botp.modified_on = DateTime.Now; var json2 = new JavaScriptSerializer().Serialize(botp); log.json_after = json2; db.t_audit_log.Add(log); db.SaveChanges(); result.Entity = entity; } else { result.Success = false; result.ErrorMessage = " Bootcamp Type not found"; } } } return(result); }