Beispiel #1
0
        public async Task <IEnumerable <Employee> > GetEmployees()
        {
            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)
                {
                    EmployeeDoc employeeResume = new EmployeeDoc();
                    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);
        }
Beispiel #2
0
        public Employee GetEmployee(Int32 id)
        {
            var employee = this._employeeService.Get(id);

            if (employee == null)
            {
                return(null);
            }

            Employee employeeModel = new Employee();

            foreach (var resume in employee.EmployeeResumes)
            {
                EmployeeDoc employeeResume = new EmployeeDoc();
                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;

            return(employeeModel);
        }
Beispiel #3
0
        public MethodResult <EmployeeDoc> Update(EmployeeDoc model)
        {
            var result = new MethodResult <EmployeeDoc>();

            this._upRepository.EmployeeDocs.Attach(model);
            this._upRepository.SaveChanges();
            result.Result = model;
            return(result);
        }
Beispiel #4
0
        public HttpResponseMessage CreateNewInfor(HttpRequestMessage request, EmployeeDoc Employeeinfor)
        {
            Data data = new Data();

            if (data.CheckID(Employeeinfor) == true)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotModified));
            }
            else
            {
                return(request.CreateResponse(HttpStatusCode.OK, data.InsertInfor(Employeeinfor)));
            }
        }
Beispiel #5
0
        public ActionResult EditEmployeeDoc(EditEmployeeDoc editEmployeeDoc)
        {
            ViewBag.Path1 = "上传资料>";
            var employee = db.Employee.Include(a => a.EmployeeDocs).Where(a => a.UserId == WebSecurity.CurrentUserId && a.Id == editEmployeeDoc.EmployeeId).SingleOrDefault();

            if (employee == null)
            {
                return(HttpNotFound());
            }

            if (employee.EmployeeStatus != EmployeeStatus.新增已通知)
            {
                return(RedirectToAction("FrontDetail"));
            }

            if (ModelState.IsValid)
            {
                var old = new HashSet <int>(employee.GetEmployeeDocs().Select(a => a.Id));
                var cur = new HashSet <int>(editEmployeeDoc.EditSingleEmployeeDocs.Where(a => a.EmployeeDocId != 0).Select(a => a.EmployeeDocId));

                // 取得在最新列表中的记录更新
                var upd = (from a in old
                           where cur.Contains(a)
                           select a).ToList();
                foreach (var i in upd)
                {
                    var e1 = db.EmployeeDoc.Find(i);
                    var e2 = editEmployeeDoc.EditSingleEmployeeDocs.Where(a => a.EmployeeDocId == i).Single();
                    e1.ImgPath = e2.ImgPath;
                }
                // end

                // 取得在最新列表中的记录添加
                var add = editEmployeeDoc.EditSingleEmployeeDocs.Where(a => !String.IsNullOrWhiteSpace(a.ImgPath) && a.EmployeeDocId == 0);
                foreach (var i in add)
                {
                    var e = new EmployeeDoc {
                        EmployeeId = employee.Id, DocumentId = i.DocumentId, ImgPath = i.ImgPath
                    };
                    employee.EmployeeDocs.Add(e);
                }
                // end
                db.PPSave();
                return(RedirectToAction("FrontDetail"));
            }

            return(View(editEmployeeDoc));
        }
Beispiel #6
0
        public async Task <HttpResponseMessage> PutEmployee(Int32 employeeId, EmployeeModel model)
        {
            HttpResponseMessage result = null;

            if (employeeId == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            Employee employee = this._employeeService.Get(employeeId);

            if (employee == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            employee.FirstName = model.FirstName;
            employee.LastName  = model.LastName;
            this._employeeService.Add(employee);
            Employee employeeModel = new 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);
                    EmployeeDoc employeeResume = new EmployeeDoc();
                    var         maxId          = this._employeeResumeService.GetMaxId();
                    var         fileResult     = await this._employeeResumeService.AddFileAsync(Constants.Azure.Containers.PageEmployeeAssets, maxId, file.FileName, stream);

                    employeeResume.Link       = fileResult.FullPath;
                    employeeResume.Name       = fileResult.Name;
                    employeeResume.EmployeeId = employee.Id;
                    this._employeeResumeService.Add(employeeResume);
                    employeeModel.EmployeeResumes.Add(employeeResume);
                }
            }

            employeeModel.FirstName = employee.FirstName;
            employeeModel.LastName  = employee.LastName;
            employeeModel.Id        = employee.Id;
            result = Request.CreateResponse(HttpStatusCode.OK, employeeModel);
            return(result);
        }
Beispiel #7
0
        public async Task <HttpResponseMessage> DeleteEmployeeDocument(Int32?employeeId, Int32?resumeId)
        {
            HttpResponseMessage result = null;

            if (!employeeId.HasValue || !resumeId.HasValue)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            EmployeeDoc empDoc = this._employeeResumeService.Get(resumeId.Value);

            if (empDoc == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            this._employeeResumeService.DeleteEmployeeDocument(employeeId.Value, resumeId.Value);
            return(Request.CreateResponse(HttpStatusCode.OK, empDoc));
        }
 public virtual MethodResult <EmployeeDoc> Update(EmployeeDoc model)
 {
     return(this._employeeDocRepository.Update(model));
 }
 public virtual MethodResult <EmployeeDoc> Add(EmployeeDoc model)
 {
     return(this._employeeDocRepository.Add(model));
 }