public void UpdateContact(EmployeeContactsRole con) { var selectContact = (from contact in _db.Contacts where contact.ContactID == con.ContactID select contact).FirstOrDefault(); selectContact.FirstName = con.FirstName; selectContact.LastName = con.LastName; selectContact.Email = con.Email; selectContact.Address = con.Address; selectContact.ContactNumber = con.ContactNumber; selectContact.EmergencyContactNumber = con.EmergencyContactNumber; selectContact.ProfilePicture = con.ProfilePicture; selectContact.ModifiedTimeStamp = con.ModifiedTimeStamp; _db.Contacts.Update(selectContact); _db.SaveChanges(); }
public async Task <IActionResult> PostEmployees([FromBody] EmployeeContactsRole employees) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _employee.PostEmployee(employees); return(Ok()); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> PutEmployees([FromRoute] int id, [FromBody] EmployeeContactsRole employees) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employees.EmployeeID) { return(BadRequest()); } _employee.PutEmployee(employees); return(Ok()); }
public void PutEmployee(EmployeeContactsRole emp) { using (IDbConnection db = new SqlConnection(_connectionString)) { try { var parameter = new DynamicParameters(); parameter.Add("@Designation", emp.Designation); parameter.Add("@IsFullTimer", emp.IsFullTimer); parameter.Add("@Salary", emp.Salary); parameter.Add("@ModifiedTimeStamp", emp.ModifiedTimeStamp); parameter.Add("@EmployeeID", emp.EmployeeID); db.Execute("UpdateEmployee", parameter, commandType: CommandType.StoredProcedure); } catch (Exception ex) { throw ex; } } }
public async Task <IActionResult> UpdateContact([FromRoute] int id, [FromBody] EmployeeContactsRole contacts) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contacts.ContactID) { return(BadRequest()); } try { _employee.UpdateContact(contacts); return(Ok()); } catch (Exception ex) { throw ex; } }
public void PostEmployee(EmployeeContactsRole emp) { //var data = new Employee(); using (IDbConnection db = new SqlConnection(_connectionString)) { try { if (emp.FirstName != null && emp.LastName != null && emp.Address != null && emp.Email != null && emp.ContactNumber != null && emp.EmergencyContactNumber != null && emp.ProfilePicture != null && emp.Designation != null && emp.Salary != null && emp.UserName != null && emp.IsFullTimer != null && emp.Password != null && emp.RoleID != null) { var parameter = new DynamicParameters(); parameter.Add("@FirstName", emp.FirstName); parameter.Add("@LastName", emp.LastName); parameter.Add("@Address", emp.Address); parameter.Add("@Email", emp.Email); parameter.Add("@ContactNumber", emp.ContactNumber); parameter.Add("@EmergyContactNumber", emp.EmergencyContactNumber); parameter.Add("@ProfilePicture", emp.ProfilePicture); parameter.Add("@Designation", emp.Designation); parameter.Add("@Salary", emp.Salary); parameter.Add("@IsFullTimer", emp.IsFullTimer); parameter.Add("@IsWorking", emp.IsWorking); parameter.Add("@UserName", emp.UserName); parameter.Add("@Password", emp.Password); parameter.Add("@RoleID", emp.RoleID); parameter.Add("@DepartmentID", emp.DepartmentID); parameter.Add("@CreatedTimeStamp", emp.CreatedTimeStamp); db.Execute("InsertIntoContactsAndEmployee", parameter, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { throw ex; } } }