public async Task <IEnumerable <Employee> > Get() { var result = await this._employeeService.GetAll(); List <Employee> model = new List <Employee>(); foreach (var employee in result) { Employee employeeModel = new Employee(); foreach (var resume in employee.EmployeeResumes) { EmployeeResume employeeResume = new EmployeeResume(); employeeResume.EmployeeId = resume.EmployeeId; employeeResume.Name = resume.Name; employeeResume.Link = resume.Link; employeeResume.Id = resume.Id; employeeModel.EmployeeResumes.Add(employeeResume); } employeeModel.FirstName = employee.FirstName; employeeModel.LastName = employee.LastName; employeeModel.Id = employee.Id; model.Add(employeeModel); } return(model); }
public virtual MethodResult <EmployeeResume> Update(EmployeeResume model) { var result = new MethodResult <EmployeeResume>(); this._upRepository.EmployeeResumes.Attach(model); this._upRepository.SaveChanges(); result.Result = model; return(result); }
public async Task <HttpResponseMessage> PutEmployee(EmployeeModel model) { HttpResponseMessage result = null; if (!model.Id.HasValue) { result = Request.CreateResponse(HttpStatusCode.BadRequest); } Employee employee = this._employeeService.Get(model.Id.Value); if (employee == null) { result = Request.CreateResponse(HttpStatusCode.BadRequest); } employee.FirstName = model.FirstName; employee.LastName = model.LastName; this._employeeService.Add(employee); if (model.Files != null && model.Files.Count > 0) { foreach (var file in model.Files) { MemoryStream stream = new MemoryStream(); stream.Write(file.Buffer, 0, file.Buffer.Length); EmployeeResume employeeResume = new EmployeeResume(); employeeResume.Id = Guid.NewGuid(); var fileResult = await this._employeeService.AddFileAsync(Constants.Azure.Containers.PageAssets, employeeResume.Id.Value, file.FileName, stream); employeeResume.Link = fileResult.FullPath; employeeResume.Name = fileResult.Name; employeeResume.EmployeeId = employee.Id.Value; this._employeeResumeService.Add(employeeResume); } Employee employeeModel = new Employee(); foreach (var resume in employee.EmployeeResumes) { EmployeeResume employeeResume = new EmployeeResume(); employeeResume.EmployeeId = resume.EmployeeId; employeeResume.Name = resume.Name; employeeResume.Link = resume.Link; employeeResume.Id = resume.Id; employeeModel.EmployeeResumes.Add(employeeResume); } employeeModel.FirstName = employee.FirstName; employeeModel.LastName = employee.LastName; employeeModel.Id = employee.Id; result = Request.CreateResponse(HttpStatusCode.Created, employeeModel); } return(result); }
public virtual MethodResult <EmployeeResume> Add(EmployeeResume model) { var result = new MethodResult <EmployeeResume>(); model.IsDeleted = false; model.CreatedDate = DateTime.UtcNow; model.UpdatedDate = model.CreatedDate; this._upRepository.EmployeeResumes.Add(model); this._upRepository.SaveChanges(); result.Result = model; return(result); }