//public EntityResult<IEnumerable<BLL_ChkCategoryTree>> UpdateCheckList(BLL_CheckListParameter bLL_checklist) public EntityResult <BLL_ChkCategoryTree> UpdateCheckList(BLL_CheckListParameter bLL_checklist) { return(RunInContextScope(() => { return _checklistManager.UpdateCheckList(bLL_checklist); })); }
private void AssignDefaults(TbChklistval currentval, BLL_CheckListParameter newEntity) { DateTime dtchekdatetime = DateTime.Now; try { IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-US", true); dtchekdatetime = DateTime.ParseExact(newEntity.CompletedDateTime, "MM/dd/yyyy HH:mm:ss", theCultureInfo); newEntity.Completed = dtchekdatetime; } catch (Exception ex) { throw new NotFoundAPIException("Invalid Date format to MM/dd/yyyy HH:mm:ss"); } newEntity.PersonName = GetPersonNameByID(newEntity.PersonId); currentval.Key1 = newEntity.Dealnumber; currentval.Chklistnum = newEntity.Checklistnum; currentval.Completed = Convert.ToDateTime(newEntity.Completed); currentval.Entitynum = newEntity.Entitynum ?? 1;//default to deal currentval.PersonId = newEntity.PersonId; currentval.Userid = newEntity.PersonName; currentval.Key2 = -1; currentval.Key3 = -1; }
public EntityResult <BLL_ChkCategoryTree> UpdateCheckList(BLL_CheckListParameter bll_checklist) { int workflow = -1; try { int dealcheckedstaus = _CheckListRepository.IsValidDealCheckedStatus(bll_checklist.Dealnumber, bll_checklist.Checklistnum); if (dealcheckedstaus == -1) { throw new NotFoundAPIException("Deal and Checklistnumber combination are not found"); } int checklistAddstatus = -1; TbChklistval chklistvaldata = null; if (bll_checklist.check == true && dealcheckedstaus == 0) { checklistAddstatus = AddChekcList(bll_checklist); workflow = 1; } else if (bll_checklist.check == true && dealcheckedstaus == 1) { chklistvaldata = _CheckListRepository.Get(d => d.Key1 == bll_checklist.Dealnumber && d.Chklistnum == bll_checklist.Checklistnum); if (chklistvaldata.PersonId == bll_checklist.PersonId) { OnApplyChanges(chklistvaldata, bll_checklist); _CheckListRepository.Save(chklistvaldata); } else { throw new NotFoundAPIException("Update is failed due to PersonID is different."); } workflow = 2; } else if (bll_checklist.check == false && dealcheckedstaus == 1) { DeleteCheckListByTaskID(bll_checklist.Checklistnum, bll_checklist.Dealnumber); workflow = 3; return(null); } else if (bll_checklist.check == false && dealcheckedstaus == 0) { throw new NotFoundAPIException("Checklist number not found"); } if (workflow != -1) { return(GetCheckNumByDealChecklists(bll_checklist.Dealnumber, bll_checklist.Checklistnum)); } else { throw new NotFoundAPIException("Record not found"); } } catch (Exception ex) { throw ex; } }
private void OnApplyChanges(TbChklistval currentView, BLL_CheckListParameter newEntity) { newEntity.PersonName = GetPersonNameByID(newEntity.PersonId); if (newEntity.Notes == null) { throw new NotFoundAPIException("Note Parameter is not found"); } else if (newEntity.Notes.Length > 200) { throw new NotFoundAPIException("Note Character cannot be more than 200"); } else { currentView.Notes = newEntity.Notes; currentView.Key1 = newEntity.Dealnumber; currentView.Chklistnum = newEntity.Checklistnum; } }
private int AddChekcList(BLL_CheckListParameter bLL_chklist) { int status = -1; try { TbChklistval tbUserView = new TbChklistval(); AssignDefaults(tbUserView, bLL_chklist); _CheckListRepository.Add(tbUserView); _CheckListRepository.Save(tbUserView); status = 1; } catch (Exception ex) { throw new NotFoundAPIException("Input value is not valid"); } return(status); }
public IHttpActionResult Put(int dealnumber, int checklistnum, ChkCategoryTree checklist) { if (checklist == null) { return(BadRequest("No Parameter found")); } if (dealnumber < 1) { return(BadRequest("Invalid value in Deal Number")); } if (checklist.DealNumber != 0) { if (checklist.DealNumber != dealnumber) { return(BadRequest("JSON Input and Route value of Deal Number are not equal")); } } if (checklistnum < 1) { return(BadRequest("Invalid value in checklist number")); } checklist.DealNumber = dealnumber; BLL_CheckListParameter bLL_CheckListParameter = new BLL_CheckListParameter(); bLL_CheckListParameter.Dealnumber = dealnumber; bLL_CheckListParameter.Checklistnum = checklistnum; if (checklist.Checklists != null) { if (checklist.Checklists[0].ChkListNum != 0) { if (checklist.Checklists[0].ChkListNum != checklistnum) { return(BadRequest("JSON Input and Route value of CheckList Number are not equal")); } } if (checklist.Checklists[0].Checked == null) { return(BadRequest("Checked parameter is required")); } bLL_CheckListParameter.check = checklist.Checklists[0].Checked; bLL_CheckListParameter.PersonId = checklist.Checklists[0].PersonId; bLL_CheckListParameter.CompletedDateTime = checklist.Checklists[0].CheckedDateTime; bLL_CheckListParameter.Notes = checklist.Checklists[0].Note; checklist.Checklists[0].ChkListNum = checklistnum; } else { return(BadRequest("Invalid input value")); } if (checklist.EntityNum > 2 || checklist.EntityNum < 0) { return(BadRequest("Invalid value EntityNumber")); } bLL_CheckListParameter.Entitynum = checklist.EntityNum; EntityResult <BLL_ChkCategoryTree> chklistdetail = EntityManager.UpdateCheckList(bLL_CheckListParameter); if (chklistdetail == null) { Result deletchecklist = new Result(new Information("CheckList", "Successfully Deleted")); return(DeleteResponse(deletchecklist)); } return(OkResponse(chklistdetail)); }