public ActionResult <ResponseAapi <ICategory> > GetCategory(int id, [FromQuery] CategoryParam param) { var response = new ResponseAapi <ICategory>(); mBuilder.AttachCategoryEntity(id, response); var category = response.Value; // "la" if (param.lla_order == CategoryParam.LLA_ORDER_NAME_ASC) { response.Link.Add("la", category.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray()); } else if (param.lla_order == CategoryParam.LLA_ORDER_NAME_DESC) { response.Link.Add("la", category.GetContentList().OrderByDescending(prop => prop.Name).Select(prop => prop.Id).ToArray()); } else { response.Link.Add("la", category.GetContentList().Select(prop => prop.Id).ToArray()); } // "cc" var ccQuery = this.mCategoryRepository.FindChildren(category); response.Link.Add("cc", ccQuery.Select(prop => prop.Id).ToArray()); // 拡張機能の呼び出し this.mExtentionManager.Execute(ExtentionCutpointType.API_GET_CATEGORY, category); return(response); }
public ActionResult <ReplyModel> Add([FromBody] CategoryParam msg) { ReplyModel replyModel = new ReplyModel(); Expression <Func <Category, bool> > func = w => w.Title == msg.Title; CategoryDto category = CategoryDto.GetCategoryInfo(_categoryQuery, msg.Title); if (category == null) { Category.Add(_categoryRepository, msg.Title, msg.Description); bool result = ServiceProvider.GetService <IUnitOfWork>().Commit(); if (result) { replyModel.Status = "002"; replyModel.Msg = "添加标题成功"; } else { replyModel.Msg = "添加标题失败"; } } else { replyModel.Msg = "该分类已经存在"; } return(replyModel); }
public async Task <Result> Update([FromBody] CategoryParam model, int id) { var category = await _categoryRepository.FirstOrDefaultAsync(id); if (category == null) { return(Result.Fail("单据不存在")); } category.Name = model.Name; category.Slug = model.Slug; category.MetaTitle = model.MetaTitle; category.MetaKeywords = model.MetaKeywords; category.MetaDescription = model.MetaDescription; category.Description = model.Description; category.DisplayOrder = model.DisplayOrder; category.ParentId = model.ParentId; category.IncludeInMenu = model.IncludeInMenu; category.IsPublished = model.IsPublished; category.MediaId = model.MediaId; category.UpdatedOn = DateTime.Now; if (category.ParentId.HasValue && await HaveCircularNesting(category.Id, category.ParentId.Value)) { return(Result.Fail("Parent category cannot be itself children")); } await _categoryService.Update(category); await _categoryService.ClearCache(); return(Result.Ok()); }
public object DeleteCategory(CategoryParam MP) { try { Tbl_Category_Master objcategory = db.Tbl_Category_Master.Where(r => r.CategoryID == MP.CategoryID).FirstOrDefault(); if (objcategory.Status == 1) { objcategory.Status = 0; } else { objcategory.Status = 1; } db.SaveChanges(); return(new Result() { IsSucess = true, ResultData = "Category Updated Successfully!" }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public bool Insert(CategoryParam categoryParam) { if (categoryParam != null) { status = _categoryRepository.Insert(categoryParam); } return(status); }
public bool Update(int?Id, CategoryParam categoryParam) { if (Id != null && categoryParam != null) { status = _categoryRepository.Update(Id, categoryParam); } return(status); }
public object SaveCategory(CategoryParam MP) { try { string msg = ""; if (MP.BtnStatus == "Save") { var usercode = db.Tbl_Category_Master.Where(r => r.CategoryName == MP.CategoryName.ToUpper()).FirstOrDefault(); if (usercode != null) { return(new Error() { IsError = true, Message = "Category Name Already Exists!" }); } Tbl_Category_Master objCategory = new Tbl_Category_Master(); objCategory.CategoryName = MP.CategoryName.ToUpper(); objCategory.CreatedBy = MP.CreatedBy; objCategory.CreatedDate = DateTime.Now; objCategory.Status = 1; db.Tbl_Category_Master.Add(objCategory); db.SaveChanges(); msg = "Category Saved Successfully!"; } else { Tbl_Category_Master objCategory = db.Tbl_Category_Master.Where(r => r.CategoryID == MP.CategoryID).FirstOrDefault(); var data = db.Tbl_Category_Master.Where(r => r.CategoryName == MP.CategoryName).FirstOrDefault(); if (data != null) { return(new Error() { IsError = true, Message = "Category Name Already Exists!" }); } objCategory.CategoryName = MP.CategoryName.ToUpper(); objCategory.ModifiedDate = DateTime.Now; objCategory.CategoryID = MP.CategoryID; db.SaveChanges(); msg = "Category Updated Successfully!"; } return(new Result() { IsSucess = true, ResultData = msg }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public CategoryGroupWithCategoriesList CategoriesByGroup([FromUri] CategoryParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (!(param.StartPoint.HasValue || (param.StartPointAlias == null))) { param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias)); } return(new CategoryGroupWithCategoriesList(ExcursionProvider.GetCategoriesByGroup(param.Language, param.StartPoint))); }
public bool Insert(CategoryParam categoryParam) { var result = 0; category.Name = categoryParam.Name; category.CreateDate = DateTimeOffset.UtcNow.LocalDateTime; myContext.Categories.Add(category); result = myContext.SaveChanges(); if (result > 0) { status = true; } return(status); }
public bool Insert(CategoryParam categoryParam) { if (categoryParam == null) { Console.WriteLine("Insert Name"); Console.Read(); } else { status = _categoryRepository.Insert(categoryParam); Console.WriteLine("Success"); } return(status); }
public bool Update(int?Id, CategoryParam categoryParam) { var result = 0; var category = Get(Id); category.Name = categoryParam.Name; category.UpdateDate = DateTimeOffset.UtcNow.LocalDateTime; result = myContext.SaveChanges(); if (result > 0) { status = true; } return(status); }
public object GetSingleCategory(CategoryParam objgr) { try { var SingleCategorylist = db.ViewCategoryLists.Where(r => r.CategoryID == objgr.CategoryID).FirstOrDefault(); return(SingleCategorylist); } catch (Exception E) { return(new Error() { IsError = true, Message = E.Message }); } }
public Response Create(CategoryParam param) { Response response = new Response(); try { response.Text = "This entity has been added :" + Environment.NewLine + JsonConverter.JsonConverter.ObjToJson(Processor.Create(param)); response.Result = true; } catch { response.Text = "Unfortunately something went wrong. Are you sure that the entity you are trying to create doesn't already exist ?"; response.Result = false; } return(response); }
public object GetSingleCategoryInfo([FromBody] CategoryParam OBJGR) { try { CasteBL obj = new CasteBL(); var SingleGR = obj.GetSingleCategory(OBJGR); return(SingleGR); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public object SaveCategory([FromBody] CategoryParam PR) { try { CasteBL OBJSAVE = new CasteBL(); var result = OBJSAVE.SaveCategory(PR); return(result); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }
public object DeleteCategory([FromBody] CategoryParam MP) { try { CasteBL obj = new CasteBL(); var result = obj.DeleteCategory(MP); return(result); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }
public Response Update(long id, CategoryParam param) { Response response = new Response(); try { Processor.Update(id, param); response.Text = "The entity has been updated."; response.Result = true; } catch { response.Text = "The command was unable to execute. Are you sure the entity you want to update exists."; response.Result = false; } return(response); }
public object GetCategoryMaster([FromBody] CategoryParam objid) { try { var status = objid.Status; CasteBL obj = new CasteBL(); var ERPCategory = obj.GetCategoryList(status); return(ERPCategory); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public ResponseAapi <ICategory> GetCategory(int id, [FromQuery] CategoryParam param) { var response = new ResponseAapi <ICategory>(); var category = this.categoryRepository.Load(id); if (category != null) { response.Value = category; // "la" if (param.lla_order == CategoryParam.LLA_ORDER_NAME_ASC) { response.Link.Add("la", category.GetContentList().OrderBy(prop => prop.Name).Select(prop => prop.Id).ToArray()); } else if (param.lla_order == CategoryParam.LLA_ORDER_NAME_DESC) { response.Link.Add("la", category.GetContentList().OrderByDescending(prop => prop.Name).Select(prop => prop.Id).ToArray()); } else { response.Link.Add("la", category.GetContentList().Select(prop => prop.Id).ToArray()); } // "cc" var ccQuery = this.categoryRepository.FindChildren(category); response.Link.Add("cc", ccQuery.Select(prop => prop.Id).ToArray()); } else { throw new InterfaceOperationException("カテゴリが見つかりません"); } try { // 拡張機能の呼び出し this.extentionManager.Execute(ExtentionCutpointType.API_GET_CATEGORY, category); } catch (Exception expr) { _logger.Error(expr.Message); throw new InterfaceOperationException(); } return(response); }
public bool Update(int?Id, CategoryParam categoryParam) { if (Id == null) { Console.WriteLine("Insert Id"); Console.Read(); } else if (Id == ' ') { Console.WriteLine("Dont Insert Blank Caracter"); Console.Read(); } else { status = _categoryRepository.Update(Id, categoryParam); Console.WriteLine("update Success"); } return(status); }
public async Task <IActionResult> GetProductByCategories([FromBody] CategoryParam category) { try { var data = _categoriesClientService.GetProductByCategory(category.Id); _logger.LogError("Lấy dữ liệu thành công"); return(Ok(new Result() { Code = (int)HttpStatusCode.OK, Data = data, Error = "" })); } catch (Exception ex) { _logger.LogError("Lấy dữ liệu thất bại"); return(Ok(new Result() { Code = (int)HttpStatusCode.OK, Data = null, Error = ex.Message })); } }
public async Task <Result> Get(int id) { var category = await _categoryRepository.Query().Include(x => x.Media).FirstOrDefaultAsync(c => c.Id == id); var model = new CategoryParam { Id = category.Id, Name = category.Name, Slug = category.Slug, MetaTitle = category.MetaTitle, MetaKeywords = category.MetaKeywords, MetaDescription = category.MetaDescription, DisplayOrder = category.DisplayOrder, Description = category.Description, ParentId = category.ParentId, IncludeInMenu = category.IncludeInMenu, IsPublished = category.IsPublished, MediaId = category.MediaId, ThumbnailImageUrl = await _mediaService.GetThumbnailUrl(category.Media), }; return(Result.Ok(model)); }
public async Task <Result> Create([FromBody] CategoryParam model) { var category = new Category { Name = model.Name, Slug = model.Slug, MetaTitle = model.MetaTitle, MetaKeywords = model.MetaKeywords, MetaDescription = model.MetaDescription, DisplayOrder = model.DisplayOrder, Description = model.Description, ParentId = model.ParentId, IncludeInMenu = model.IncludeInMenu, IsPublished = model.IsPublished, MediaId = model.MediaId }; await _categoryService.Create(category); await _categoryService.ClearCache(); return(Result.Ok()); }
public void Update(long id, CategoryParam param) { Data.Entity.Category oldEntity = Dao.Find(id); Data.Entity.Category newEntity = ParamConverter.Convert(param, oldEntity); Dao.Update(newEntity); }
public CategoryResult Create(CategoryParam param) { Data.Entity.Category entity = ParamConverter.Convert(param, null); entity = Dao.Save(entity); return(ResultConverter.Convert(entity)); }
// POST: api/Priorities public void Post(CategoryParam CategoryParam) { _categoryService.Insert(CategoryParam); }
// PUT: api/Priorities/5 public void Put(int id, CategoryParam CategoryParam) { _categoryService.Update(id, CategoryParam); }
public void ValidateParameters(CategoryParam param) { throw new NotImplementedException(); }