Exemplo n.º 1
0
        public ActionResult EditBrand(Guid NidBrand)
        {
            dbTransfer = new DbTransfer();
            Category_Brands brand = dbTransfer.GetCategoryBrandByNidBrand(NidBrand);

            return(Json(new JsonBnTEdit()
            {
                Description = brand.Description, Keywords = brand.Keywords, Name = brand.BrandName, Nid = brand.NidBrand.ToString()
            }));
        }
Exemplo n.º 2
0
 public Category_BrandDTO MapToCategory_BrandDTO(Category_Brands category_brand)
 {
     try
     {
         return(mapper.Map <Category_BrandDTO>(category_brand));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public ActionResult ManageBrand(bool IsNewBrand, string Name, int NidCategory, string Description = "", string Keywords = "", string NidBrand = "")
 {
     dbTransfer = new DbTransfer();
     if (IsNewBrand)
     {
         Category_Brands cb = new Category_Brands()
         {
             BrandName = Name, NidBrand = Guid.NewGuid(), Description = Description, Keywords = Keywords, NidCategory = NidCategory
         };
         dbTransfer.Add(cb);
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در دیتابیس"
             }));
         }
     }
     else
     {
         Category_Brands cb = dbTransfer.GetCategoryBrandByNidBrand(Guid.Parse(NidBrand));
         cb.BrandName = Name; cb.Description = Description; cb.Keywords = Keywords;
         dbTransfer.Update(cb);
         if (dbTransfer.Save())
         {
             return(Json(new JsonResults()
             {
                 HasValue = true
             }));
         }
         else
         {
             return(Json(new JsonResults()
             {
                 HasValue = false, Message = "خطا در دیتابیس"
             }));
         }
     }
 }
Exemplo n.º 4
0
        public ActionResult AddBrandOrType(bool IsBrand, string Name, bool IsNewCategory, string CategoryName = "", int NidCategory = 0, string categoryKeywords = "", string CategoryDescription = "")
        {
            dbTransfer = new DbTransfer();
            bool categoryAdded  = false;
            bool brandAdded     = false;
            bool typeAdded      = false;
            int  tmpNidcategory = 0;

            if (IsNewCategory)
            {
                tmpNidcategory = dbTransfer.GenerateNewNidCategory();
                Category category = new Category()
                {
                    CategoryName = CategoryName, IsSubmmited = false, NidCategory = tmpNidcategory, Description = CategoryDescription, keywords = categoryKeywords
                };
                dbTransfer.Add(category);
                if (dbTransfer.Save())
                {
                    categoryAdded = true;
                }
                else
                {
                    return(Json(new JsonResults()
                    {
                        HasValue = false, Message = "خطا در اضافه کردن دسته بندی"
                    }));
                }
            }
            else
            {
                tmpNidcategory = NidCategory;
                categoryAdded  = true;
            }
            if (IsBrand)
            {
                Category_Brands categoryBrand = new Category_Brands()
                {
                    NidBrand = Guid.NewGuid(), BrandName = Name, NidCategory = tmpNidcategory
                };
                dbTransfer.Add(categoryBrand);
                if (dbTransfer.Save())
                {
                    brandAdded = true;
                }
                else
                {
                    return(Json(new JsonResults()
                    {
                        HasValue = false, Message = "خطا در اضافه کردن برند"
                    }));
                }
            }
            else
            {
                Category_Types categoryType = new Category_Types()
                {
                    NidType = Guid.NewGuid(), NidCategory = tmpNidcategory, TypeName = Name
                };
                dbTransfer.Add(categoryType);
                if (dbTransfer.Save())
                {
                    typeAdded = true;
                }
                else
                {
                    return(Json(new JsonResults()
                    {
                        HasValue = false, Message = "خطا در اضافه کردن نوع"
                    }));
                }
            }
            if (categoryAdded)
            {
                List <Tuple <string, string, bool> > labels = new List <Tuple <string, string, bool> >();
                if (brandAdded)
                {
                    foreach (var lbl in dbTransfer.GetCategoryBrandsByNidCategory(tmpNidcategory))
                    {
                        labels.Add(new Tuple <string, string, bool>(lbl.NidBrand.ToString(), lbl.BrandName, true));
                    }
                }
                if (typeAdded)
                {
                    foreach (var lbl in dbTransfer.GetCategoryTypesByNidCategory(tmpNidcategory))
                    {
                        labels.Add(new Tuple <string, string, bool>(lbl.NidType.ToString(), lbl.TypeName, false));
                    }
                }
                return(Json(new JsonResults()
                {
                    HasValue = true, Html = RenderViewToString(this.ControllerContext, "_CategoryBrandAndTypeLabel", labels), tmpNidCategory = tmpNidcategory
                }));
            }
            else
            {
                return(Json(new JsonResults()
                {
                    HasValue = false, Message = "خطای ناشناخته"
                }));
            }
        }