public long CategoryAdd(SqlConnection db, NewCategoryData obj)
        {
            string sql = @"INSERT INTO [ProductCategory] 
                          (Name) 
                          VALUES 
                          (@Name); 
                          SELECT CAST(SCOPE_IDENTITY() as bigint)";

            return(db.Query <long>(sql, new { obj.Name }).Single());
        }
        public ActionResult <string> Token_AdminCreateCategory([FromBody] NewCategoryData obj)
        {
            if (!this.features.CreateCategory.Execute)
            {
                return(BadRequest(new ServiceError
                {
                    Message = this.features.CreateAccount.ErrorMessage
                }));
            }

            return(ExecuteRemoteService(obj, token: true));
        }
Beispiel #3
0
        private void FeedCategoryTree_CreateCategory(NewCategoryData newCategoryData)
        {
            var category = newCategoryData.Category;

            if (category == null)
            {
                return;
            }

            var createdCategory = _categoryService.CreateCategory(category);

            var treeComponent = new TreeComponent(createdCategory);

            var parentComponent = newCategoryData.ParentTreeComponent ?? _subscriptionsComponent;

            parentComponent.SubComponents.Add(treeComponent);
            parentComponent.IsExpanded = true;
        }
        public bool Exec(SqlConnection db, NewCategoryData obj)
        {
            if (string.IsNullOrEmpty(obj.Name))
            {
                Error = new ServiceError {
                    Message = "Name is empty"
                };
                return(false);
            }

            if (repository.CategoryExists(db, obj.Name))
            {
                Error = new ServiceError {
                    Message = "Name already exists"
                };
                return(false);
            }

            IdCreated = repository.CategoryAdd(db, obj);

            return(true);
        }
Beispiel #5
0
        public bool Exec(SqlConnection db, NewCategoryData obj)
        {
            if (string.IsNullOrEmpty(obj.Name))
            {
                Error = new ServiceError {
                    Message = "Name is empty!"
                };
                return(false);
            }

            if (!repository.CategoryExistsId(db, obj.Id))
            {
                Error = new ServiceError {
                    Message = "Id invalid!"
                };
                return(false);
            }

            repository.CategoryEdit(db, obj);

            return(true);
        }
Beispiel #6
0
        public ActionResult <string> CreateCategory([FromBody] NewCategoryData obj)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminCreateCategoryV1(repository);

                    if (!service.Exec(db, obj))
                    {
                        return(BadRequest(service.Error));
                    }

                    return(Ok(new { Id = service.IdCreated }));
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new ServiceError {
                    DebugInfo = ex.ToString(), Message = _defaultError
                }));
            }
        }
 public ActionResult <string> Token_AdminEditCategory([FromBody] NewCategoryData obj)
 {
     return(ExecuteRemoteService(obj, token: true));
 }
Beispiel #8
0
 public void CategoryEdit(SqlConnection db, NewCategoryData obj)
 {
 }
Beispiel #9
0
 public long CategoryAdd(SqlConnection db, NewCategoryData obj)
 {
     return(1);
 }
 public void CategoryEdit(SqlConnection db, NewCategoryData obj)
 {
     db.Query(@"update [ProductCategory] set Name=@Name where Id=@Id", new { obj.Name, obj.Id });
 }