public ActionResult Edit([Bind(Include = "SIMCardId,SerialNumber,GSM,SIMCardStatusId,CreateUserId,CreateDate")] SIMCard EditItem) { if (ModelState.IsValid) { //for test EditItem.ModifyUserId = 1; EditItem.ModifyDate = DateTime.Now; new SIMCardModel <SIMCard>().Update(EditItem, EditItem.SIMCardId); TempData["AlertMessage"] = new AlertMessage() { MessageType = AlertMessageType.Success, MessageContent = "1 item has been updated" }; return(RedirectToAction("Index")); } var SIMCardStatus = new SIMCardStatusModel <SIMCardStatus>().Get(); var model = new EditSIMCardModel() { EditItem = new SIMCardModel <SIMCard>().Get(EditItem.SIMCardId), Status = SIMCardStatus.Select(x => new SelectListItem() { Selected = EditItem.SIMCardStatusId == x.SIMCardStatusId, Text = x.SIMCardStatusName_en, Value = x.SIMCardStatusId.ToString() }) }; return(View(model)); }
// GET: SIMCards/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SIMCard SimCard = new SIMCardModel <SIMCard>().Get((int)id); if (SimCard == null) { return(HttpNotFound()); } var SIMCardStatus = new SIMCardStatusModel <SIMCardStatus>().Get(); var model = new EditSIMCardModel() { EditItem = SimCard, Status = SIMCardStatus.Select(x => new SelectListItem() { Selected = SimCard.SIMCardStatusId == x.SIMCardStatusId, Text = x.SIMCardStatusName_en, Value = x.SIMCardStatusId.ToString() }) }; return(View(model)); }