public ActionResult EditType(Guid NidType) { dbTransfer = new DbTransfer(); Category_Types type = dbTransfer.GetCategoryTypeByNidType(NidType); return(Json(new JsonBnTEdit() { Description = type.Description, Keywords = type.Keywords, Name = type.TypeName, Nid = type.NidType.ToString() })); }
public Category_TypeDTO MapToCategory_TypeDTO(Category_Types category_type) { try { return(mapper.Map <Category_TypeDTO>(category_type)); } catch (Exception) { return(null); } }
public ActionResult ManageType(bool IsNewType, string Name, int NidCategory, string Description = "", string Keywords = "", string NidType = "") { dbTransfer = new DbTransfer(); if (IsNewType) { Category_Types cb = new Category_Types() { TypeName = Name, NidType = 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_Types cb = dbTransfer.GetCategoryTypeByNidType(Guid.Parse(NidType)); cb.TypeName = 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 = "خطا در دیتابیس" })); } } }
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 = "خطای ناشناخته" })); } }