Example #1
0
        public ActionResult Update(int id)
        {
            var franchisee = _franchiseeTenantService.GetById(id);
            var viewModel  = new DashboardFranchiseeModuleDataViewModel
            {
                SharedViewModel = new DashboardFranchiseeModuleShareViewModel()
                {
                    Id             = franchisee.Id,
                    FranchiseeName = franchisee.Name,
                    FranchiseeId   = franchisee.Id
                }
            };

            return(View(viewModel));
        }
Example #2
0
        public ActionResult Update(FranchiseeTenantParameter parameters)
        {
            var viewModel = MapFromClientParameters(parameters);

            byte[] lastModified            = null;
            var    franchiseeTenant        = _franchiseeTenantService.GetById(viewModel.SharedViewModel.Id);
            var    mappedFranchiseeTenant  = viewModel.MapPropertiesToInstance(franchiseeTenant);
            var    franchiseeConfiguration = viewModel.MapTo <FranchiseeConfiguration>();

            var sharViewModel = viewModel.SharedViewModel as DashboardFranchiseeTenantShareViewModel;
            var logoFilePath  = "";

            if (ModelState.IsValid)
            {
                if (sharViewModel != null)
                {
                    if (!String.IsNullOrEmpty(sharViewModel.Logo))
                    {
                        if (!sharViewModel.Logo.Contains("data:image/jpg;base64"))
                        {
                            logoFilePath = Server.MapPath(sharViewModel.Logo);
                            franchiseeConfiguration.Logo = System.IO.File.ReadAllBytes(logoFilePath);//_resizeImage.ResizeImageByHeight(logoFilePath, 40);
                        }
                    }
                    else
                    {
                        franchiseeConfiguration.Logo = Convert.FromBase64String("NULL");
                    }
                    if (String.IsNullOrEmpty(sharViewModel.Address2))
                    {
                        franchiseeConfiguration.Address2 = "";
                    }
                    if (String.IsNullOrEmpty(sharViewModel.PrimaryContactFax))
                    {
                        franchiseeConfiguration.PrimaryContactFax = "";
                    }
                    if (String.IsNullOrEmpty(sharViewModel.PrimaryContactEmail))
                    {
                        franchiseeConfiguration.PrimaryContactEmail = "";
                    }
                    if (String.IsNullOrEmpty(sharViewModel.PrimaryContactCellNumber))
                    {
                        franchiseeConfiguration.PrimaryContactCellNumber = "";
                    }
                }
                lastModified = _franchiseeTenantService.UpdateFranchisee(mappedFranchiseeTenant, franchiseeConfiguration);
            }

            return(Json(new { Error = string.Empty, Data = new { LastModified = lastModified } }, JsonRequestBehavior.AllowGet));
        }