public UpdateLeadInformation(NewLeadsData newLeadsData)
 {
     NavigationPage.SetBackButtonTitle(this, "");
     InitializeComponent();
     BindingContext = _updateInformationViewModel = new UpdateInformationViewModel(Navigation);
     _updateInformationViewModel.Initialize(newLeadsData);
 }
Exemple #2
0
        public async Task <IActionResult> UpdateInformation(UpdateInformationViewModel data)
        {
            var model = new Customer
            {
                CustomerId       = _session.GetInt32("CustomerId").Value,
                CustomerAddress  = data.CustomerAddress,
                CustomerPhone    = data.CustomerPhone,
                CustomerFullname = data.CustomerFullname
            };

            var result = await _customerService.UpdateInformation(model);

            if (result)
            {
                return(Json(new
                {
                    success = true
                }));
            }

            return(Json(new
            {
                success = false,
                message = "Cập nhật thất bại"
            }));
        }
Exemple #3
0
        public ActionResult UpdateInformation(UpdateInformationViewModel model, HttpPostedFileBase image, string TimeZone)
        {
            var timezones = TimeZoneInfo.GetSystemTimeZones();

            ViewBag.TimeZone = new SelectList(timezones, "Id", "Id");

            var pPic = model.NewProfilePic;

            if (image != null && image.ContentLength > 0)
            {
                var ext = Path.GetExtension(image.FileName).ToLower();
                if (ext != ".png" && ext != ".jpg" && ext != ".jpeg" && ext != ".gif" && ext != ".bmp")
                {
                    ModelState.AddModelError("image", "Invalid Format.");
                }
            }

            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    //Counter
                    var num = 0;
                    //Gets Filename without the extension
                    var fileName = Path.GetFileNameWithoutExtension(image.FileName);
                    pPic = Path.Combine("/Assets/ProfilePics/", fileName + Path.GetExtension(image.FileName));
                    //Checks if pPic matches any of the current attachments,
                    //if so it will loop and add a (number) to the end of the filename
                    while (db.Users.AsNoTracking().Any(u => u.ProfilePic == pPic))
                    {
                        //Sets "filename" back to the default value
                        fileName = Path.GetFileNameWithoutExtension(image.FileName);
                        //Add's parentheses after the name with a number ex. filename(4)
                        fileName = string.Format(fileName + "(" + ++num + ")");
                        //Makes sure pPic gets updated with the new filename so it could check
                        pPic = Path.Combine("/Assets/ProfilePics/", fileName + Path.GetExtension(image.FileName));
                    }
                    image.SaveAs(Path.Combine(Server.MapPath("~/Assets/ProfilePics/"), fileName + Path.GetExtension(image.FileName)));
                }

                var defaultProfilePic = "~/Assets/images/Profile_avatar_placeholder_large.png";
                if (String.IsNullOrWhiteSpace(pPic))
                {
                    pPic = defaultProfilePic;
                }

                var user = UserManager.FindById(User.Identity.GetUserId());
                user.FirstName  = model.NewFirstName;
                user.LastName   = model.NewLastName;
                user.ProfilePic = pPic;
                user.Bio        = model.Bio;
                user.TimeZone   = model.TimeZone;
                UserManager.Update(user);

                return(RedirectToAction("UserProfile", "Account", new { Message = ManageMessageId.UpdateInformationSuccess }));
            }

            return(View(model));
        }
        //GET: /Manage/UpdateInformation
        public ActionResult UpdateInformation()
        {
            var user = UserManager.FindById(User.Identity.GetUserId());
            UpdateInformationViewModel model = new UpdateInformationViewModel();

            model.NewFirstName = user.FirstName;
            model.NewLastName  = user.LastName;
            //model.NewProfilePic = user.ProfilePic;

            return(View(model));
        }
        public ActionResult UpdateInformation(UpdateInformationViewModel model, HttpPostedFileBase image)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = UserManager.FindById(User.Identity.GetUserId());

            var pPic = model.ProfilePic;

            if (ImageUploadValidator.IsWebFriendlyImage(image))
            {
                //Counter
                var num = 0;
                //Gets Filename without the extension
                var fileName = Path.GetFileNameWithoutExtension(image.FileName);
                pPic = Path.Combine("/ProfilePics/", fileName + Path.GetExtension(image.FileName));
                //Checks if pPic matches any of the current attachments,
                //if so it will loop and add a (number) to the end of the filename
                while (db.Users.Any(u => u.ProfilePic == pPic))
                {
                    //Sets "filename" back to the default value
                    fileName = Path.GetFileNameWithoutExtension(image.FileName);
                    //Add's parentheses after the name with a number ex. filename(4)
                    fileName = string.Format(fileName + "(" + ++num + ")");
                    //Makes sure pPic gets updated with the new filename so it could check
                    pPic = Path.Combine("/ProfilePics/", fileName + Path.GetExtension(image.FileName));
                }
                image.SaveAs(Path.Combine(Server.MapPath("~/ProfilePics/"), fileName + Path.GetExtension(image.FileName)));
            }

            var defaultMedia = "/assets/images/DefaultProfilePic.png";

            if (String.IsNullOrWhiteSpace(user.ProfilePic))
            {
                pPic = defaultMedia;
            }

            user.FirstName   = model.FirstName;
            user.LastName    = model.LastName;
            user.DisplayName = model.FirstName + ' ' + model.LastName;
            user.PhoneNumber = model.PhoneNumber;
            user.Company     = model.Company;
            user.JobTitle    = model.JobTitle;
            user.ProfilePic  = pPic;

            UserManager.Update(user);

            return(RedirectToAction("Index", new { Message = ManageMessageId.UpdateInformationSuccess }));
        }
        //
        // GET: /Manage/UpdateInformation
        public ActionResult UpdateInformation()
        {
            var user  = UserManager.FindById(User.Identity.GetUserId());
            var model = new UpdateInformationViewModel();

            model.FirstName   = user.FirstName;
            model.LastName    = user.LastName;
            model.PhoneNumber = user.PhoneNumber;
            model.Company     = user.Company;
            model.JobTitle    = user.JobTitle;
            model.ProfilePic  = user.ProfilePic;

            return(View(model));
        }
Exemple #7
0
        public async Task <PartialViewResult> UpdateInformation()
        {
            var customerId = _session.GetInt32("CustomerId").Value;

            var result = await _customerService.GetCustomerById(customerId);

            var model = new UpdateInformationViewModel
            {
                CustomerFullname = result.CustomerFullname,
                CustomerPhone    = result.CustomerPhone,
                CustomerAddress  = result.CustomerAddress
            };

            return(PartialView("~/Views/Account/_UpdateInformationPartial.cshtml", model));
        }
Exemple #8
0
        //GET: /Manage/UpdateInformation
        public ActionResult UpdateInformation()
        {
            var timezones = TimeZoneInfo.GetSystemTimeZones();

            ViewBag.TimeZone = new SelectList(timezones, "Id", "Id");

            var user = UserManager.FindById(User.Identity.GetUserId());
            UpdateInformationViewModel model = new UpdateInformationViewModel();

            model.NewFirstName  = user.FirstName;
            model.NewLastName   = user.LastName;
            model.NewProfilePic = user.ProfilePic;
            model.Bio           = user.Bio;
            model.TimeZone      = user.TimeZone;

            return(View(model));
        }