public ActionResult Add(Category objCategory) { objCategory.AddedBy = "Admin"; objCategory.AddedOn = DateTime.Now; int i = cDAl.AddCategory(objCategory); if (i == 0) { ViewBag.Message = "Data Added Successfully"; } return(View(objCategory)); }
public bool AddCategory(Category category) { List <Category> categories = GetCategories(); foreach (var item in categories) { if (item.Name == category.Name) { return(false); } } return(categoriesDal.AddCategory(category)); }
public HttpResponseMessage AddCategory(Category category) { ResponseMessage <CategoryModel> objResponseData = new ResponseMessage <CategoryModel>(); try { CategoryModel categoryModel = new CategoryModel(); if (objCategoryDAL.GetAllCategories().ToList().Any(cat => cat.CategoryName != category.CategoryName)) { Category newCategory = objCategoryDAL.AddCategory(category); if (newCategory.CategoryId > 0) { //mapping categoryModel = Mapper.Map <Category, CategoryModel>(newCategory, categoryModel); objResponseData = ResponseHandler <CategoryModel> .CreateResponse(objResponseData, "Successfully Added A New Category.", categoryModel, HttpStatusCode.OK); } else { //mapping categoryModel = Mapper.Map <Category, CategoryModel>(category, categoryModel); objResponseData = ResponseHandler <CategoryModel> .CreateResponse(objResponseData, "Can't Add This Category.", HttpStatusCode.Conflict); } } else // category name is already present { //mapping categoryModel = Mapper.Map <Category, CategoryModel>(category, categoryModel); objResponseData = ResponseHandler <CategoryModel> .CreateResponse(objResponseData, "This category is already available.", categoryModel, HttpStatusCode.Conflict); } } catch (System.Exception ex) { objErrorLogger.ErrorLog(ex); objResponseData = ResponseHandler <CategoryModel> .CreateErrorResponse(objResponseData); } return(Request.CreateResponse(objResponseData.StatusCode, objResponseData)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="entity"></param> public void AddCategory(Category entity) { service.AddCategory(entity); }
public bool AddCategory(string CategoryName) { return(categoryDAL.AddCategory(CategoryName)); }
public static void AddCategory(Category category) { CategoryDAL.AddCategory(category); }
public void AddCategory(Category category) { _db.AddCategory(category); }