public ActionResult Edit(EditProfileForm form)
 {
     if (ModelState.IsValid)
     {
         D.Employee e = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             FirstName   = form.FirstName,
             LastName    = form.LastName,
             Address     = form.Address,
             Phone       = form.Phone
         };
         try
         {
             if (EmployeeService.Update(e))
             {
                 return(RedirectToAction("Index"));
             }
         }
         catch (Exception exception)
         {
             throw (exception);
         }
     }
     return(View(form));
 }
 public ActionResult EditEmail(EditEmailForm form)
 {
     if (ModelState.IsValid)
     {
         D.Employee e = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             Email       = form.Email,
             Passwd      = form.Passwd
         };
         try
         {
             if (EmployeeService.UpdateEmail(e))
             {
                 return(RedirectToAction("Index"));
             }
             ModelState.AddModelError("Passwd", "Mot de passe incorrect");
         }
         catch (System.Data.SqlClient.SqlException exeption)
         {
             if (exeption.Number == 2627)
             {
                 if (exeption.Message.Contains("UC_Email"))
                 {
                     ModelState.AddModelError("Email", "Cet email est déjà utilisé");
                 }
             }
         }
     }
     return(View(form));
 }
 public ActionResult EditPass(EditPassForm form)
 {
     if (ModelState.IsValid)
     {
         string     OldPass = form.OldPass;
         D.Employee e       = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             Passwd      = form.NewPass
         };
         try
         {
             if (EmployeeService.UpdatePassword(e, OldPass))
             {
                 return(RedirectToAction("Index"));
             }
             ModelState.AddModelError("OldPass", "Mot de passe incorrect");
         }
         catch (Exception exception)
         {
             throw (exception);
         }
     }
     return(View());
 }
Beispiel #4
0
 // Global Employee to Client Employee
 internal static C.Employee ToClient(this G.Employee entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(new C.Employee(
                entity.Id,
                entity.LastName,
                entity.FirstName,
                entity.Email,
                entity.Password,
                entity.RegNat,
                entity.HireDate,
                entity.Active,
                entity.Avatar,
                entity.City,
                entity.Street,
                entity.Number,
                entity.NumberBox,
                entity.ZipCode,
                entity.Country,
                entity.GSM,
                entity.BirthDate));
 }
Beispiel #5
0
 internal static C.Employee ToLoginClient(this G.Employee emp)
 {
     if (emp == null)
     {
         return(null);
     }
     return(new C.Employee(emp.Id, emp.Email));
 }
        // GET: Employee/Profile/Edit/
        public ActionResult Edit()
        {
            D.Employee      e    = EmployeeService.Get(SessionUser.GetUser().Id);
            EditProfileForm form = new EditProfileForm()
            {
                FirstName = e.FirstName,
                LastName  = e.LastName,
                Address   = e.Address,
                Phone     = e.Phone
            };

            return(View(form));
        }
 internal static C.Employee ToClient(this G.Employee entity)
 {
     return(new C.Employee(entity.Employee_Id, entity.LastName, entity.FirstName, entity.Email, entity.Passwd,
                           entity.Actif, entity.RegNat, entity.CoordGps, entity.Address, entity.Phone, entity.IsAdmin));
 }