Пример #1
0
        public void UpdateAdminIfo(AdminInfoViewModel _adminInfo)
        {
            Data.EmployeeInfo _employee = _context.EmployeeInfoes.Find(_adminInfo.EmployeeInfoId);

            if (_employee != null)
            {
                _employee.FirstName            = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_adminInfo.FirstName.ToLower());
                _employee.LastName             = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_adminInfo.LastName.ToLower());
                _employee.DateOfBirth          = _adminInfo.DateOfBirth;
                _employee.CellNumber           = _adminInfo.CellNumber;
                _employee.ResidencePhoneNumber = _adminInfo.ResidencePhoneNumber;
                _employee.MaritalStatus        = _adminInfo.MaritalStatus;
                _employee.PersonalEmail        = _adminInfo.PersonalEmail.ToLower();
                _employee.CNIC             = _adminInfo.CNIC;
                _employee.PermanentAddress = _adminInfo.PermanentAddress;
                _employee.PresentAddress   = _adminInfo.PresentAddress;
                _employee.TotalExperience  = _adminInfo.ExperienceYears + "," + _adminInfo.ExperienceMonths;

                _context.SaveChanges();
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
Пример #2
0
        private void Edit(AdminDisplayModel adminDisplayModel)
        {
            AdminEditModel admin = new AdminEditModel
            {
                FirstName   = adminDisplayModel.FirstName,
                LastName    = adminDisplayModel.LastName,
                PhoneNumber = adminDisplayModel.PhoneNumber,
                Login       = adminDisplayModel.Login
            };

            AdminInfoViewModel viewModel = new AdminInfoViewModel(admin);
            AdminInfoControl   control   = new AdminInfoControl(viewModel);
            Window             window    = WindowFactory.CreateByContentsSize(control);

            viewModel.AdminEdited += (s, e) =>
            {
                AdminEditModel adminEditModel = e.Admin;
                AdminEditDTO   adminEditDTO   = Mapper.Map <AdminEditModel, AdminEditDTO>(adminEditModel);

                using (IAdminService service = factory.CreateAdminService())
                {
                    ServiceMessage serviceMessage = service.Update(adminEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #3
0
        public PartialViewResult Header()
        {
            var model = new AdminInfoViewModel();

            if (AbpSession.UserId.HasValue)
            {
                model = new AdminInfoViewModel
                {
                    LoginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations())
                };
            }
            return(PartialView("_Header", model));
        }
Пример #4
0
        // GET: Admin/Profile/UpdateMyInfo
        public ActionResult UpdateMyInfo()
        {
            try
            {
                if (CurrentUser.Role != "SuperAdmin")
                {
                    return(RedirectToAction("Dashboard", "Home"));
                }

                AdminInfoViewModel _adminInfoModel = new AdminInfoViewModel();

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    _adminInfoModel = Repo.GetAdminInfoById(CurrentUser.EmployeeInfoId);
                }

                return(View(_adminInfoModel));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Profile", "UpdateMyInfo")));
            }
        }
Пример #5
0
        public ActionResult UpdateMyInfo(HttpPostedFileBase file, AdminInfoViewModel _adminInfoModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                if (CurrentUser.Role != "SuperAdmin")
                {
                    return(RedirectToAction("Dashboard", "Home"));
                }

                bool isImgSelected = false;

                if (file != null)
                {
                    if (file.ContentType.Contains("image"))
                    {
                        if (file.ContentLength < 2 * 1024 * 1024)
                        {
                            if (file.FileName.Contains(".jpeg") || file.FileName.Contains(".jpg"))
                            {
                                isImgSelected = true;
                            }
                            else
                            {
                                TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select jpeg, jpg format only.");

                                return(View());
                            }
                        }
                        else
                        {
                            TempData["Msg"] = AlertMessageProvider.FailureMessage("Please select size upto 2 MB or smaller.");

                            return(View());
                        }
                    }
                    else
                    {
                        TempData["Msg"] = AlertMessageProvider.FailureMessage("Invalid content type, please select image only.");

                        return(View());
                    }
                }

                _adminInfoModel.EmployeeInfoId      = CurrentUser.EmployeeInfoId;
                _adminInfoModel.ModifiedDate        = DateTime.Now;
                _adminInfoModel.ModifiedByAccountId = CurrentUser.AccountId;

                using (EmployeeRepository Repo = new EmployeeRepository())
                {
                    Repo.UpdateAdminIfo(_adminInfoModel);

                    TempData["Msg"] = AlertMessageProvider.SuccessMessage("Information updated successfully.");
                }

                if (isImgSelected == true)
                {
                    string imgPath = Server.MapPath(Url.Content("~/Content/Employee_pictures/" + CurrentUser.AccountId + ".jpg"));
                    file.SaveAs(imgPath);
                }

                return(RedirectToAction("UpdateMyInfo", "Profile"));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Profile", "UpdateMyInfo")));
            }
        }
Пример #6
0
 public AdminInfoControl(AdminInfoViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }