public async Task <ActionResult> UserCompleteMainInfo(DomainLayer.DB_Model.Employee.Employee model) { model.OwnerUserId = Guid.Parse(User.Identity.GetUserId()); model.AppUserId = Guid.Parse(User.Identity.GetUserId()); HttpPostedFileBase photo = Request.Files["pictureFile"]; if (photo != null && photo.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(photo.InputStream)) { model.Picture = reader.ReadBytes(photo.ContentLength); } } if (ModelState.IsValid) { var result = await _employeeService.CreateAsync(model); if (result.Success) { return(RedirectToAction("Index", "Manage", new { @area = "Authentication", Message = ManageMessageId.CompleteMainInfo })); } ModelState.AddModelError("", "Error In Savin DataBase Please Tell SystemAdministrator"); } else { ModelState.AddModelError("", "Your Information Not Valid For Save To DataBase Check Again"); } return(View(model)); }
public async Task <ServicesResult> UpdateAsync(DomainLayer.DB_Model.Employee.Employee employee) { try { _uow.MarkAsChanged(employee); await _uow.SaveChangesAsync(); return(new ServicesResult() { Success = true }); } catch (Exception ex) { return(new ServicesResult() { Success = false, Message = ex.Message, InnerExeption = ex.InnerException.Message, }); } }
public async Task <ServicesResult> CreateAsync(DomainLayer.DB_Model.Employee.Employee employee) { try { //کد ملی تکراری مورد قبول نیست var existEmployee = DuplicateNationalId(employee.NationalId); if (existEmployee) { return(new ServicesResult() { Success = false, Message = "کد ملی تکراری است" }); } _employee.Add(employee); await _uow.SaveChangesAsync(); return(new ServicesResult() { Success = true }); } catch (Exception ex) { return(new ServicesResult() { Success = false, Message = ex.Message, InnerExeption = ex.InnerException.Message, }); } }