Example #1
0
        public void SaveEditDistributorConfigurationContents(DistributorConfigurationModel model)
        {
            LogoResizer logoResizer = new LogoResizer();
            var         ts          = SessionStore.GetTravelSession();
            var         Data        = entity.LayoutSetting.Where(x => x.LayoutSettingId == model.LayoutSettingId).FirstOrDefault();

            Data.DistributorId            = ts.LoginTypeId;
            Data.Title                    = model.Title;
            Data.ContactUs                = model.ContactUs;
            Data.IsContactUsActive        = model.IsContactUsActive;
            Data.DashboardContent         = model.DashboardContent;
            Data.IsDashboardContentActive = model.IsDashboardContentActive;
            Data.HeaderContact            = model.HeaderContact;
            Data.IsHeaderContactActive    = model.IsHeaderContactActive;
            Data.ScrollNews               = model.ScrollNews;
            Data.BankInfo                 = model.BankInfo;
            Data.IsBankInfoActive         = model.IsBankInfoActive;
            Data.IsLogoActive             = model.IsLogoActive;
            Data.IsPublished              = model.IsPublished;
            Data.CreatedBy                = ts.AppUserId;
            Data.CreatedDate              = DateTime.UtcNow;

            if (model.Logo != null)
            {
                if (model.Logo.ContentLength > 0)
                {
                    switch (model.Logo.ContentType)
                    {
                    case "image/jpeg":
                    case "image/pjpeg":
                    case "image/gif":
                    case "image/png":

                        Data.ImageType = model.Logo.ContentType;
                        Int32  length   = model.Logo.ContentLength;
                        byte[] tempFile = new byte[length];
                        model.Logo.InputStream.Read(tempFile, 0, model.Logo.ContentLength);
                        tempFile  = logoResizer.ValidatePicture(tempFile, model.Logo.ContentType);
                        Data.Logo = tempFile;
                        break;
                    }
                }
            }

            entity.ApplyCurrentValues(Data.EntityKey.EntitySetName, Data);
            entity.SaveChanges();
        }
Example #2
0
        public bool SaveCreateDistributorConfigurationContents(DistributorConfigurationModel model)
        {
            LogoResizer   logoResizer = new LogoResizer();
            var           ts          = SessionStore.GetTravelSession();
            LayoutSetting distributorConfigurationModelToSave = new LayoutSetting()
            {
                DistributorId            = ts.LoginTypeId,
                Title                    = model.Title,
                ContactUs                = model.ContactUs,
                IsContactUsActive        = model.IsContactUsActive,
                DashboardContent         = model.DashboardContent,
                IsDashboardContentActive = model.IsDashboardContentActive,
                IsLogoActive             = model.IsLogoActive,
                HeaderContact            = model.HeaderContact,
                IsHeaderContactActive    = model.IsHeaderContactActive,
                ScrollNews               = model.ScrollNews,
                IsScrollNewsActive       = model.IsScrollNewsActive,
                BankInfo                 = model.BankInfo,
                IsBankInfoActive         = model.IsBankInfoActive,
                CreatedBy                = ts.AppUserId,
                CreatedDate              = DateTime.UtcNow
            };

            if (model.Logo.ContentLength > 0)
            {
                switch (model.Logo.ContentType)
                {
                case "image/jpeg":
                case "image/pjpeg":
                case "image/gif":
                case "image/png":

                    distributorConfigurationModelToSave.ImageType = model.Logo.ContentType;
                    Int32  length   = model.Logo.ContentLength;
                    byte[] tempFile = new byte[length];
                    model.Logo.InputStream.Read(tempFile, 0, model.Logo.ContentLength);
                    tempFile = logoResizer.ValidatePicture(tempFile, model.Logo.ContentType);
                    distributorConfigurationModelToSave.Logo = tempFile;
                    break;
                }
            }
            entity.AddToLayoutSetting(distributorConfigurationModelToSave);
            entity.SaveChanges();
            return(true);
        }