public ActionResult <string> Token_AdminCreateSubCategory([FromBody] NewSubCategoryData obj)
        {
            if (!this.features.CreateSubCategory.Execute)
            {
                return(BadRequest(new ServiceError
                {
                    Message = this.features.CreateAccount.ErrorMessage
                }));
            }

            return(ExecuteRemoteService(obj, token: true));
        }
        public long SubCategoryAdd(SqlConnection db, NewSubCategoryData obj)
        {
            string sql = @"INSERT INTO [ProductSubCategory] 
                          (ProductCategoryID,Name) 
                          VALUES 
                          (@ProductCategoryID,@Name); 
                          SELECT CAST(SCOPE_IDENTITY() as bigint)";

            return(db.Query <long>(sql, new
            {
                obj.ProductCategoryID,
                obj.Name
            }).
                   Single());
        }
        public bool Exec(SqlConnection db, NewSubCategoryData obj)
        {
            if (string.IsNullOrEmpty(obj.Name))
            {
                Error = new ServiceError {
                    Message = "Name is empty!"
                };
                return(false);
            }

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

            repository.SubCategoryEdit(db, obj);

            return(true);
        }
        public bool Exec(SqlConnection db, NewSubCategoryData obj)
        {
            if (obj.ProductCategoryID == 0)
            {
                Error = new ServiceError {
                    Message = "CategoryID is empty"
                };
                return(false);
            }

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

            if (string.IsNullOrEmpty(obj.Name))
            {
                Error = new ServiceError {
                    Message = "Name is empty"
                };
                return(false);
            }

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

            IdCreated = repository.SubCategoryAdd(db, obj);

            return(true);
        }
Exemple #5
0
        public ActionResult <string> EditSubCategory([FromBody] NewSubCategoryData obj)
        {
            try
            {
                using (var db = new SqlConnection(GetDBConnectionString()))
                {
                    var service = new AdminEditSubCategoryV1(repository);

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

                    return(Ok());
                }
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new ServiceError {
                    DebugInfo = ex.ToString(), Message = _defaultError
                }));
            }
        }
 public ActionResult <string> Token_AdminEditSubCategory([FromBody] NewSubCategoryData obj)
 {
     return(ExecuteRemoteService(obj, token: true));
 }
Exemple #7
0
 public long SubCategoryAdd(SqlConnection db, NewSubCategoryData obj)
 {
     return(1);
 }
Exemple #8
0
 public void SubCategoryEdit(SqlConnection db, NewSubCategoryData obj)
 {
 }
 public void SubCategoryEdit(SqlConnection db, NewSubCategoryData obj)
 {
     db.Query(@"update [ProductSubCategory] set Name=@Name where Id=@Id", new { obj.Name, obj.Id });
 }