Ejemplo n.º 1
0
        public ActionResult EditDinerProfile(string identifier)
        {
            if (Session != null && Session.Contents != null)
            {
                AuthenticatedUserInfo authenticatedUserInfo = Session["loggeduser"] as AuthenticatedUserInfo;

                if (authenticatedUserInfo != null)
                {
                    UserDTO userDTO = EntityDTOHelper.GetEntityDTO <DAL.User, UserDTO>(new CEUserManager().FindById(
                                                                                           int.Parse(DataSecurityTripleDES.GetPlainText(authenticatedUserInfo.UserId))));

                    CraveatsDinerViewModel craveatsDinerViewModel = null;

                    if (((Common.UserTypeEnum)userDTO.UserTypeFlag).HasFlag(Common.UserTypeEnum.CraveatsDiner))
                    {
                        craveatsDinerViewModel = new CraveatsDinerViewModel()
                        {
                            Id            = userDTO.Id,
                            ContactNumber = userDTO.ContactNumber,
                            Email         = userDTO.EmailAddress,
                            FirstName     = userDTO.FirstName,
                            Surname       = userDTO.Surname,
                            Role          = Common.UserTypeEnum.CraveatsDiner.GetDescription()
                        };
                    }
                    return(View("EditDinerProfile", craveatsDinerViewModel));
                }
            }
            return(View("Error"));
        }
Ejemplo n.º 2
0
        public ActionResult EditDinerProfile(CraveatsDinerViewModel model, string returnUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                CEUserManager ceUserManager = new CEUserManager();
                if (model.Id?.Length > 0)
                {
                    UserDTO userDTO = new UserDTO()
                    {
                        Id            = model.Id,
                        FirstName     = model.FirstName,
                        Surname       = model.Surname,
                        ContactNumber = model.ContactNumber,
                        LastUpdated   = DateTime.Now
                    };

                    ceUserManager.SaveUserDetail(userDTO);

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

                ModelState.AddModelError(string.Empty, "Save attempt failed.");

                //ModelState.AddModelError(string.Empty, "Login attempt failed.");
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e);
            }
            return(this.View(model));
        }
Ejemplo n.º 3
0
        public ActionResult CraveatsDiner(CraveatsDinerViewModel model)
        {
            if (Session != null && Session.Contents != null)
            {
                AuthenticatedUserInfo authenticatedUserInfo = Session["loggeduser"] as AuthenticatedUserInfo;

                if (authenticatedUserInfo != null)
                {
                    UserDTO userDTO = EntityDTOHelper.GetEntityDTO <DAL.User, UserDTO>(new CEUserManager().FindById(
                                                                                           int.Parse(DataSecurityTripleDES.GetPlainText(authenticatedUserInfo.UserId))));

                    CraveatsDinerViewModel craveatsDinerViewModel = null;

                    if (((Common.UserTypeEnum)userDTO.UserTypeFlag).HasFlag(Common.UserTypeEnum.CraveatsDiner))
                    {
                        craveatsDinerViewModel = new CraveatsDinerViewModel()
                        {
                            Id            = userDTO.Id,
                            ContactNumber = userDTO.ContactNumber,
                            Email         = userDTO.EmailAddress,
                            FirstName     = userDTO.FirstName,
                            Surname       = userDTO.Surname,
                            Role          = Common.UserTypeEnum.CraveatsDiner.GetDescription()
                        };
                    }

                    DataProvider dataProvider = new DataProvider();
                    if (userDTO.AddressId?.Length > 0)
                    {
                        DAL.Address anAddress = dataProvider.FindAddressById(
                            int.Parse(DataSecurityTripleDES.GetPlainText(userDTO.AddressId)));

                        AddressViewModel addressViewModel = EntityDTOHelper.GetEntityDTO <DAL.Address, AddressViewModel>(anAddress);

                        if (anAddress != null)
                        {
                            DAL.Region region = dataProvider.FindRegionById(anAddress.RegionId ?? 0);

                            if (region != null)
                            {
                                addressViewModel.RegionAlias = region.RegionAlias;
                                addressViewModel.RegionId    = DataSecurityTripleDES.GetEncryptedText(region.Id);
                            }

                            craveatsDinerViewModel.Addresses = new List <AddressViewModel>()
                            {
                                addressViewModel
                            };
                        }
                    }
                    else
                    {
                        craveatsDinerViewModel.Addresses = new List <AddressViewModel>()
                        {
                        };
                    }

                    return(View("CraveatsDiner", craveatsDinerViewModel));
                }
            }

            return(View("Error"));
        }