Esempio n. 1
0
        public ActionResult AdminEditMainInfo(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            var userId   = id.Value;
            var employee = _employeeService.Find(userId);

            if (employee == null)
            {
                return(RedirectToAction("Index", "UsersAdmin", new { @area = "Authentication" }));
            }
            var vmModel = new VMEmployeeEdit()
            {
                FirstName  = employee.FirstName,
                LastName   = employee.LastName,
                FatherName = employee.FatherName,
                BirthDay   = employee.BirthDay,
            };

            return(View(vmModel));
        }
Esempio n. 2
0
        public async Task <ActionResult> AdminEditMainInfo(VMEmployeeEdit model, Guid?id)
        {
            if (ModelState.IsValid)
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }


                var userId   = id.Value;
                var employee = _employeeService.Find(userId);


                employee.FirstName  = model.FirstName;
                employee.LastName   = model.LastName;
                employee.FatherName = model.FatherName;
                employee.BirthDay   = model.BirthDay;

                HttpPostedFileBase photo = Request.Files["pictureFile"];

                if (photo != null && photo.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(photo.InputStream))
                    {
                        employee.Picture = reader.ReadBytes(photo.ContentLength);
                    }
                }



                var result = await _employeeService.UpdateAsync(employee);

                if (result.Success)
                {
                    return(RedirectToAction("Index", "UsersAdmin", new { @area = "Authentication" }));
                }
                ModelState.AddModelError("", "Error In Savin DataBase Please Tell System Administrator");
            }
            else
            {
                ModelState.AddModelError("", "Your Information Not Valid For Save To DataBase Check Again");
            }

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult UserEditMainInfo()
        {
            var userId   = Guid.Parse(User.Identity.GetUserId());
            var employee = _employeeService.Find(userId);

            if (employee == null)
            {
                return(RedirectToAction("Index", "Manage", new { @area = "Authentication" }));
            }
            var vmModel = new VMEmployeeEdit()
            {
                FirstName  = employee.FirstName,
                LastName   = employee.LastName,
                FatherName = employee.FatherName,
                BirthDay   = employee.BirthDay,
                Image      = employee.Picture,
            };

            return(View(vmModel));
        }