public ActionResult Create([Bind(Include = "id,local_id,nvql,dia_chi,xa_phuong,to_thon,flag")] collected_staff collected_staff) { try { if (ModelState.IsValid) { //var id = PortalContext().Query("select MAX(id)+1 as id from collected_staff").First().id; //collected_staff.id = id != null ? (long)id : 1; collected_staff.created_by = Authentication.Auth.AuthUser.id.ToString(); collected_staff.created_at = DateTime.Now; db.collected_staff.Add(collected_staff); db.SaveChanges(); this.success(TM.Common.Language.msgCreateSucsess); } else { this.danger(TM.Common.Language.msgCreateError); } } catch (Exception) { this.danger("Mã nhân viên quản lý đã tồn tại"); } return(RedirectToAction("Create")); }
// GET: CollectedStaff/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } collected_staff collected_staff = db.collected_staff.Find(id); if (collected_staff == null) { return(HttpNotFound()); } return(View(collected_staff)); }
// GET: CollectedStaff/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } collected_staff collected_staff = db.collected_staff.Find(id); if (collected_staff == null) { return(HttpNotFound()); } ViewBag.local = db.locals.Where(d => d.flag > 0).ToList(); return(View(collected_staff)); }
public ActionResult Edit([Bind(Include = "id,local_id,nvql,dia_chi,xa_phuong,to_thon,flag")] collected_staff collected_staff) { try { if (ModelState.IsValid) { collected_staff.updated_by = Authentication.Auth.AuthUser.id.ToString(); collected_staff.updated_at = DateTime.Now; db.Entry(collected_staff).State = EntityState.Modified; db.SaveChanges(); this.success(TM.Common.Language.msgUpdateSucsess); return(RedirectToAction("Index")); } else { this.danger(TM.Common.Language.msgUpdateError); } } catch (Exception) { this.danger(TM.Common.Language.msgUpdateError); } return(View()); }