Beispiel #1
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));
        }
Beispiel #2
0
        public int Create(FranchiseeTenantParameter parameters)
        {
            var viewModel               = MapFromClientParameters(parameters);                                  //
            var franchiseeTenant        = viewModel.MapTo <FranchiseeTenant>();                                 //
            var franchiseeConfiguration = viewModel.MapTo <FranchiseeConfiguration>();                          //
            var sharViewModel           = viewModel.SharedViewModel as DashboardFranchiseeTenantShareViewModel; //
            var logoFilePath            = "";

            if (sharViewModel != null)
            {
                if (!String.IsNullOrEmpty(sharViewModel.Logo))
                {
                    if (!sharViewModel.Logo.Contains("data:image/jpg;base64"))
                    {
                        logoFilePath = Server.MapPath(sharViewModel.Logo);
                        franchiseeConfiguration.Logo = _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 = "";
                }
            }
            var idInsert = _franchiseeTenantService.SetupFranchisee(franchiseeTenant, franchiseeConfiguration);//

            return(idInsert);
        }