public bool Update(Employee employee) { if (employee.Code != employee.PrevCode) { if (_employeeGetway.GetByCode(employee.Code) != null) { throw new Exception("Code should be unique"); } } if (employee.ContactNo != employee.PrevContact) { if (_employeeGetway.GetByContactNo(employee.ContactNo) != null) { throw new Exception("Contact No should be unique"); } } if (employee.Email != employee.PrevEmail) { if (_employeeGetway.GetByEmail(employee.Email) != null) { throw new Exception("Email should be unique"); } } if (employee.NID != employee.PrevNID) { if (_employeeGetway.GetByNID(employee.NID) != null) { throw new Exception("NID should be unique"); } } return(_employeeGetway.Update(employee)); }
public int Update(Employee entity) { return(_employeeGetway.Update(entity)); }
public async Task <HttpResponseMessage> Post([FromBody] List <EmployeeModel> mEmployeeModel) { var formatter = RequestFormat.JsonFormaterString(); string msg = ""; try { if (string.IsNullOrEmpty(mEmployeeModel.ElementAt(0).EmCode)) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Employee Code is Empty" }, formatter)); } if (string.IsNullOrEmpty(mEmployeeModel.ElementAt(0).EmName)) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Employee Name is Empty" }, formatter)); } else { if (_gtEmployeeGetway.FncSeekRecordNew("tbl_HR_GLO_EMPLOYEE", "Id=" + mEmployeeModel.ElementAt(0).EmId + "")) { msg = await _gtEmployeeGetway.Update(mEmployeeModel); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "success", Msg = msg }, formatter)); } else { if (_gtEmployeeGetway.FncSeekRecordNew("tbl_HR_GLO_EMPLOYEE", "Code='" + mEmployeeModel.ElementAt(0).EmCode + "'")) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Employee code already exists" }, formatter)); } msg = await _gtEmployeeGetway.Save(mEmployeeModel); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "success", Msg = msg }, formatter)); } } //if (mEmployeeModel.ElementAt(0).PtIndoorId == 0) //{ // return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Name is Null" }); //} //else //{ // string msg = await _gtEmployeeGetway.Save(mEmployeeModel); // return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "success", Msg = msg }, formate); //} } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = ex.ToString() }, formatter)); } }