public static NoAssignment RegisterNoAssignment(NoAssignment noAssignment) { try { using Repository <NoAssignment> repo = new Repository <NoAssignment>(); var record = repo.NoAssignment.OrderByDescending(x => x.AddDate).FirstOrDefault(); if (record != null) { noAssignment.Code = CommonHelper.IncreaseCode(record.Code); } else { noAssignment.Code = "1"; } noAssignment.Active = "Y"; noAssignment.AddDate = DateTime.Now; repo.NoAssignment.Add(noAssignment); if (repo.SaveChanges() > 0) { return(noAssignment); } return(null); } catch (Exception ex) { throw ex; } }
public IActionResult UpdateNoAssignment([FromBody] NoAssignment noAssignments) { if (noAssignments == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(noAssignments)} cannot be null" })); } try { NoAssignment result = NoAssignmentHelper.UpdateNoAssignment(noAssignments); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation Failed" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult DeleteNoAssignment(string code) { if (string.IsNullOrWhiteSpace(code)) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(code)} cannot be null" })); } try { NoAssignment result = NoAssignmentHelper.DeleteNoAssignment(code); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = code })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Deletion Failed" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public IActionResult RegisterNoAssignment([FromBody] NoAssignment noAssignment) { try { if (NoAssignmentHelper.GetNoAssignmentList(noAssignment.Code).Count > 0) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $" code={noAssignment.Code} Already exists." })); } NoAssignment result = NoAssignmentHelper.RegisterNoAssignment(noAssignment); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = " Registration Failed" })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public static NoAssignment UpdateNoAssignment(NoAssignment noAssignment) { try { using Repository <NoAssignment> repo = new Repository <NoAssignment>(); repo.NoAssignment.Update(noAssignment); if (repo.SaveChanges() > 0) { return(noAssignment); } return(null); } catch (Exception ex) { throw ex; } }