示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }