public ActionResult DeleteAttandance(int id) { Dbcontext db = new Dbcontext(); Attandance p = (from c in db.Attandances where c.Id == id select c).FirstOrDefault(); db.Entry(p).State = EntityState.Deleted; db.SaveChanges(); return(Json("Delete", JsonRequestBehavior.AllowGet)); }
protected override void TakeFormAction() { if (CurrentActivity().CurrAction.FormDataProcessing.IsSaveRequestData) { if (WorkflowInstance.Attandance != null) { Attandance _attandance = WorkflowInstance.Attandance; bool _isUpdate = false; Attandance _CurrentAttandance = _ATDRepository.Get(p => p.request_header_id == RequestHeader.Id); if (_CurrentAttandance != null) { _CurrentAttandance.detail = _attandance.detail; _CurrentAttandance.remarks = _attandance.remarks; _CurrentAttandance.modified_by = WorkflowInstance.CurrentUser; _CurrentAttandance.modified_date = DateTime.Now; _ATDRepository.Update(_CurrentAttandance); _attandance.request_header_id = RequestHeader.Id; _isUpdate = true; } if (!_isUpdate) { WorkflowInstance.Attandance.request_header_id = RequestHeader.Id; _ATDRepository.Add(WorkflowInstance.Attandance); } } else { throw new Exception("EGM Attandance Rquest ATD have no Instance"); } } }
public ActionResult MarkAttandance(FormCollection data) { AttandanceHandler aHandler = new AttandanceHandler(); Dbcontext db = new Dbcontext(); try { if (ModelState.IsValid) { Attandance attandance = new Attandance(); attandance.AttandanceDdl = new AttandanceDDL { Id = Convert.ToInt32(data["os"]) }; attandance.DateTime = Convert.ToDateTime(data["DateTime"]); attandance.Member = new Member { Id = Convert.ToInt32(data["Id"]) }; db.Attandances.Add(attandance); db.Entry(attandance.AttandanceDdl).State = EntityState.Unchanged; db.Entry(attandance.Member).State = EntityState.Unchanged; db.SaveChanges(); return(RedirectToAction("index")); } } catch (Exception e) { ViewBag.OSList = ModelHelper.ToSelectItemList(aHandler.GetAttandances()); Console.WriteLine(e); throw; } return(RedirectToAction("Error")); }