public object GetComplaintsHistory(WorkPerson person) { if (!ModelState.IsValid) { return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.参数异常.ToString(), null)); } var data = operateContext.bllSession.T_Complaints.GetByGuid(person.userid); if (data != null) { List <ComplaintsList> rList = new List <ComplaintsList>(); ComplaintsList rCom = new ComplaintsList(); foreach (var item in data) { rCom = new ComplaintsList(); rCom.id = item.c_id; rCom.title = item.c_title; rCom.content = item.c_content; rCom.date = Convert.ToDateTime(item.create_date).ToString("yyyy-MM-dd"); rList.Add(rCom); } return(operateContext.RedirectWebApi(WebResultCode.Ok, GlobalConstant.操作成功.ToString(), rList)); } else { return(operateContext.RedirectWebApi(WebResultCode.Ok, GlobalConstant.操作成功.ToString(), null)); } }
private void AcceptDialog(object obj) { if (IsAddDialog) { if (string.IsNullOrEmpty(BriefDescription)) { AddError(nameof(BriefDescription), "Field cannot be empty"); } if (SelectedDistrict == null) { AddError(nameof(SelectedDistrict), "Field cannot be empty"); } if (!HasErrors) { var complain = new Complaint { Date = DateTime.Now, Description = BriefDescription, Status = "Not" }; var user = context.Users.FirstOrDefault(u => u.Id == UserId); var district = context.Districts.FirstOrDefault(u => u.Id == SelectedDistrict.Id); complain.User = user; complain.District = district; ComplaintsList.Add(complain); context.SaveChanges(); IsDialogOpen = false; } } else { var complain = new Complaint { Date = SelectedComplaint.Date, Description = BriefDescription, Status = "Not" }; var user = context.Users.FirstOrDefault(u => u.Id == UserId); var district = context.Districts.FirstOrDefault(u => u.Id == SelectedDistrict.Id); complain.User = user; complain.District = district; ComplaintsList.Remove(SelectedComplaint); ComplaintsList.Add(complain); context.SaveChanges(); IsDialogOpen = false; } }
private void BtnClickDeleteComplainCommand(object obj) { ComplaintsList.Remove(SelectedComplaint); context.SaveChanges(); }