コード例 #1
0
        public ViewModel.ReturnResult <bool> UpdateProjectCategory(ViewModel.ProjectCategoryModel model)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                var context = new DomainDeriven.AkoSatrapDb();

                var dbProjectCategory = context.ProjectCategories.Include("ProjectCategory2").FirstOrDefault(r => r.IsEnglish == false && r.Id == model.Id);
                if (dbProjectCategory != null)
                {
                    dbProjectCategory.Title = model.Title;
                    dbProjectCategory.ProjectCategory2.Title = model.EnTitle;
                    context.SaveChanges();
                }
                else
                {
                    returnResult.SetError("دسته بندی مورد نظر پیدا نشد");
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }
            return(returnResult);
        }
コード例 #2
0
        public ViewModel.ReturnResult <bool> AddProjectCategory(ViewModel.ProjectCategoryModel projectCategory)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                var context             = new DomainDeriven.AkoSatrapDb();
                var enDbProjectCategory = new DomainDeriven.ProjectCategory();
                var dbProjectCategory   = new DomainDeriven.ProjectCategory();

                enDbProjectCategory.Title     = projectCategory.EnTitle;
                enDbProjectCategory.IsEnglish = true;

                dbProjectCategory.Title            = projectCategory.Title;
                dbProjectCategory.IsEnglish        = false;
                dbProjectCategory.ProjectCategory2 = enDbProjectCategory;
                context.ProjectCategories.Add(dbProjectCategory);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #3
0
        public ViewModel.ReturnResult <bool> UpdateProjectFeature(ViewModel.ProjectFeatureModel projectFeature)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                var context = new DomainDeriven.AkoSatrapDb();

                var dbProjectFeature = context.ProjectFeatures.Include("ProjectFeature2")
                                       .FirstOrDefault(r => !r.IsEnglish.Value && r.Id == projectFeature.Id);

                if (dbProjectFeature != null)
                {
                    dbProjectFeature.Title = projectFeature.Title;
                    dbProjectFeature.ProjectFeature2.Title       = projectFeature.EnTitle;
                    dbProjectFeature.Description                 = projectFeature.Description;
                    dbProjectFeature.ProjectFeature2.Description = projectFeature.EnDescription;
                    dbProjectFeature.Order = projectFeature.Order;
                    dbProjectFeature.ProjectFeature2.Order = projectFeature.Order;
                    context.SaveChanges();
                }
                else
                {
                    returnResult.SetError("جزییات محصول مورد نظر پیدا نشد");
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #4
0
        public JsonResult GetBanners()
        {
            ViewModel.ReturnResult <List <string> > returnResult = new ViewModel.ReturnResult <List <string> >();
            var path = Server.MapPath($"~/fa-IR/data6/images");

            returnResult.Data = Directory.GetFiles(path).Select(r => Path.GetFileName(r)).ToList();
            return(Json(returnResult, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public JsonResult SetBanner(FileAttachment fileAttachment, string Id)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            if (fileAttachment.Attachment.ContentLength > 2097152)
            {
                returnResult.SetError("حجم فایل نمیتواند بیشتر از 2 مگابایت باشد");
                return(Json(returnResult));
            }
            var path = Server.MapPath($"~/fa-IR/data6/images/");

            System.IO.Directory.CreateDirectory(path);

            fileAttachment.Attachment.SaveAs($"{path}/{Id}");

            return(Json(returnResult));
        }
コード例 #6
0
        public ViewModel.ReturnResult <bool> AddProjectDetail(ViewModel.ProjectFeatureModel projectFeature)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                var context = new DomainDeriven.AkoSatrapDb();

                var project = context.Projects.Include("Project2").FirstOrDefault(r => r.Id == projectFeature.ProjectId);
                if (project != null)
                {
                    var enProductFeatureDb = new DomainDeriven.ProjectFeature
                    {
                        Title       = projectFeature.EnTitle,
                        Description = projectFeature.EnDescription,
                        Order       = projectFeature.Order,
                        ProjectId   = project.Project2.Id,
                        IsEnglish   = true
                    };

                    var faProjectFeatureDb = new DomainDeriven.ProjectFeature
                    {
                        Title           = projectFeature.Title,
                        Description     = projectFeature.Description,
                        Order           = projectFeature.Order,
                        ProjectFeature2 = enProductFeatureDb,
                        ProjectId       = project.Id,
                        IsEnglish       = false
                    };

                    context.ProjectFeatures.Add(faProjectFeatureDb);

                    context.SaveChanges();
                }
                else
                {
                    returnResult.SetError("محصول مورد نظر پیدا نشدُ");
                }
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #7
0
        public ViewModel.ReturnResult <bool> AddProject(ViewModel.ProjectModel project)
        {
            ViewModel.ReturnResult <bool> returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                DomainDeriven.AkoSatrapDb context = new DomainDeriven.AkoSatrapDb();
                var enDbProject = new DomainDeriven.Project();
                var dbProject   = new DomainDeriven.Project();

                enDbProject.Title                = project.EnTitle;
                enDbProject.Description          = project.EnDescription;
                enDbProject.Province             = project.EnProvince;
                enDbProject.City                 = project.EnCity;
                enDbProject.CreateDate           = DateTime.Now;
                enDbProject.StartDate            = ConvertPersianDateToGregorian(project.StartDate);
                enDbProject.EndDate              = ConvertPersianDateToGregorian(project.EndDate);
                enDbProject.CompletionPercentage = project.CompletionPercentage;
                enDbProject.ProjectCategoryId    = project.ProjectCategory != null ? project.ProjectCategory.EnId : 0;
                enDbProject.IsEnglish            = true;
                enDbProject.ImageFolderName      = Guid.NewGuid().ToString();

                dbProject.Title                = project.Title;
                dbProject.Description          = project.Description;
                dbProject.Province             = project.Province;
                dbProject.City                 = project.City;
                dbProject.CreateDate           = DateTime.Now;
                dbProject.StartDate            = ConvertPersianDateToGregorian(project.StartDate);
                dbProject.EndDate              = ConvertPersianDateToGregorian(project.EndDate);
                dbProject.CompletionPercentage = project.CompletionPercentage;
                dbProject.ProjectCategoryId    = project.ProjectCategory != null ? project.ProjectCategory.Id : 0;
                dbProject.IsEnglish            = false;
                dbProject.ImageFolderName      = Guid.NewGuid().ToString();
                dbProject.Project2             = enDbProject;

                context.Projects.Add(dbProject);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #8
0
        public ViewModel.ReturnResult <bool> AddProduct(ViewModel.ProductModel product)
        {
            ViewModel.ReturnResult <bool> returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                DomainDeriven.AkoSatrapDb context = new DomainDeriven.AkoSatrapDb();
                var enDbProduct = new DomainDeriven.Product();
                var dbProduct   = new DomainDeriven.Product();

                enDbProduct.Brand             = product.EnBrand;
                enDbProduct.CreateDate        = DateTime.Now;
                enDbProduct.ImageFolderName   = Guid.NewGuid().ToString();
                enDbProduct.ImportantTip1     = product.EnImportantTip1;
                enDbProduct.ImportantTip2     = product.EnImportantTip2;
                enDbProduct.ImportantTip3     = product.EnImportantTip3;
                enDbProduct.IsEnglish         = true;
                enDbProduct.ProductCategoryId = product.Category.EnId;
                enDbProduct.Title             = product.EnTitle;
                enDbProduct.Description       = product.EnDescription;


                dbProduct.Brand             = product.Brand;
                dbProduct.CreateDate        = DateTime.Now;
                dbProduct.ImageFolderName   = enDbProduct.ImageFolderName;
                dbProduct.ImportantTip1     = product.ImportantTip1;
                dbProduct.ImportantTip2     = product.ImportantTip2;
                dbProduct.ImportantTip3     = product.ImportantTip3;
                dbProduct.IsEnglish         = false;
                dbProduct.ProductCategoryId = product.Category.Id;
                dbProduct.Title             = product.Title;
                dbProduct.Description       = product.Description;
                dbProduct.Product2          = enDbProduct;

                context.Products.Add(dbProduct);

                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #9
0
        public ViewModel.ReturnResult <bool> UpdateProject(ViewModel.ProjectModel project)
        {
            var returnResult = new ViewModel.ReturnResult <bool>();

            try
            {
                var context = new DomainDeriven.AkoSatrapDb();

                var dbProjectCategory = context.Projects.Include("Project2").FirstOrDefault(r => r.IsEnglish == false && r.Id == project.Id);
                if (dbProjectCategory != null)
                {
                    dbProjectCategory.Title                = project.Title;
                    dbProjectCategory.Description          = project.Description;
                    dbProjectCategory.CompletionPercentage = project.CompletionPercentage;
                    dbProjectCategory.ProjectCategoryId    = project.ProjectCategory.Id;
                    dbProjectCategory.City      = project.City;
                    dbProjectCategory.Province  = project.Province;
                    dbProjectCategory.StartDate = ConvertPersianDateToGregorian(project.StartDate);
                    dbProjectCategory.EndDate   = ConvertPersianDateToGregorian(project.EndDate);

                    dbProjectCategory.Project2.Title                = project.EnTitle;
                    dbProjectCategory.Project2.Description          = project.EnDescription;
                    dbProjectCategory.Project2.City                 = project.EnCity;
                    dbProjectCategory.Project2.Province             = project.EnProvince;
                    dbProjectCategory.Project2.StartDate            = ConvertPersianDateToGregorian(project.StartDate);
                    dbProjectCategory.Project2.EndDate              = ConvertPersianDateToGregorian(project.EndDate);
                    dbProjectCategory.Project2.CompletionPercentage = project.CompletionPercentage;
                    dbProjectCategory.Project2.ProjectCategoryId    = project.ProjectCategory.Id;

                    context.SaveChanges();
                }
                else
                {
                    returnResult.SetError("دسته بندی مورد نظر پیدا نشد");
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }
コード例 #10
0
        public ViewModel.ReturnResult <bool> UpdateProduct(ViewModel.ProductModel product)
        {
            ViewModel.ReturnResult <bool> returnResult = new ViewModel.ReturnResult <bool>();
            try
            {
                DomainDeriven.AkoSatrapDb context = new DomainDeriven.AkoSatrapDb();

                var dbProductCategory = context.Products.Include("Product2").FirstOrDefault(r => r.IsEnglish == false && r.Id == product.Id);
                if (dbProductCategory != null)
                {
                    dbProductCategory.Title         = product.Title;
                    dbProductCategory.Brand         = product.Brand;
                    dbProductCategory.ImportantTip1 = product.ImportantTip1;
                    dbProductCategory.ImportantTip2 = product.ImportantTip2;
                    dbProductCategory.ImportantTip3 = product.ImportantTip3;
                    dbProductCategory.Description   = product.Description;

                    dbProductCategory.Product2.Title         = product.EnTitle;
                    dbProductCategory.Product2.Brand         = product.EnBrand;
                    dbProductCategory.Product2.ImportantTip1 = product.EnImportantTip1;
                    dbProductCategory.Product2.ImportantTip2 = product.EnImportantTip2;
                    dbProductCategory.Product2.ImportantTip3 = product.EnImportantTip3;
                    dbProductCategory.Product2.Description   = product.EnDescription;

                    context.SaveChanges();
                }
                else
                {
                    returnResult.SetError("دسته بندی مورد نظر پیدا نشد");
                }


                context.SaveChanges();
            }
            catch (Exception ex)
            {
                returnResult.SetError(ex.Message);
            }

            return(returnResult);
        }