public JsonModel GetStaffExperienceByID(int Id, TokenModel tokenModel) { StaffExperience staffExperiences = iStaffExperienceRepository.GetFirstOrDefault(a => a.Id == Id && a.IsActive == true); if (staffExperiences != null) { StaffExperienceDTO staffExperienceDTO = _mapper.Map <StaffExperienceDTO>(staffExperiences); _response = new JsonModel(staffExperienceDTO, StatusMessage.ExperienceSaved, (int)HttpStatusCode.OK); } else { _response = new JsonModel(new object(), StatusMessage.NotFound, (int)HttpStatusCode.NotFound); } return(_response); }
public StaffExperience InsertUpdateStaffExpData([FromBody] StaffExperience staffExperience) { try { if (ModelState.IsValid) { staffExperience.UpdateDate = DateTime.Now; staffExperience = _staffService.InsertUpdateStaffExp(staffExperience); } } catch (Exception ex) { throw new Exception(ex.Message); } return(staffExperience); }
public JsonModel CreateUpdateStaffExperience(StaffExperienceRequestDTO staffExperienceRequestDTO, TokenModel token) { token.UserID = 1; int result = 0; StaffExperience experience; staffExperienceRequestDTO.staffExperiences.ForEach(expModel => { experience = new StaffExperience(); expModel.StaffId = staffExperienceRequestDTO.staffId; if (expModel.Id != 0) { experience = iStaffExperienceRepository.GetFirstOrDefault(a => a.Id == expModel.Id && a.IsActive == true && a.IsDeleted == false); experience.UpdatedDate = DateTime.UtcNow; experience.UpdatedBy = token.UserID; } else { experience.CreatedBy = token.UserID; experience.CreatedDate = DateTime.UtcNow; experience.IsActive = true; experience.IsDeleted = false; } _mapper.Map(expModel, experience); if (experience.Id > 0) { iStaffExperienceRepository.Update(experience); } else { iStaffExperienceRepository.Create(experience); } iStaffExperienceRepository.SaveChanges(); result++; }); if (result > 0) { _response = new JsonModel(new object(), StatusMessage.ExperienceSaved, (int)HttpStatusCode.OK); } else { _response = new JsonModel(new object(), StatusMessage.ExperienceSaved, (int)HttpStatusCode.BadRequest); } return(_response); }
public JsonModel DeleteStaffExperience(int id, TokenModel token) { token.UserID = 1; StaffExperience staffExperiences = iStaffExperienceRepository.GetFirstOrDefault(a => a.Id == id && a.IsActive == true); if (staffExperiences != null) { staffExperiences.IsDeleted = true; staffExperiences.DeletedBy = token.UserID; staffExperiences.DeletedDate = DateTime.UtcNow; _response = new JsonModel(new object(), StatusMessage.DeleteMessage, (int)HttpStatusCode.OK); } else { _response = new JsonModel(new object(), StatusMessage.NotFound, (int)HttpStatusCode.NotFound); } return(_response); }
public StaffExperience InsertUpdateStaffExp(StaffExperience staffExperience) { return(_staffRepo.InsertUpdateStaffExp(staffExperience)); }