Exemple #1
0
        public async Task <Sub_Category_Response> SaveAsync(Sub_category sub_Category)
        {
            try{
                await sub_Category_Repository.AddAsync(sub_Category);

                await unit_Of_Work.CompleteAsync();

                return(new Sub_Category_Response(sub_Category));
            }
            catch (Exception ex) {
                return(new Sub_Category_Response($"Error while saving sub category. Message:{ex.Message}"));
            }
        }
Exemple #2
0
        public async Task <Sub_Category_Response> UpdateAsync(Sub_category sub_Category)
        {
            var isExist = await sub_Category_Repository.FindByIdAsync(sub_Category.Id);

            if (isExist == null)
            {
                return(new Sub_Category_Response("Sub category not found!"));
            }

            try
            {
                sub_Category_Repository.Update(sub_Category);
                await unit_Of_Work.CompleteAsync();

                return(new Sub_Category_Response(sub_Category));
            }
            catch (Exception ex)
            {
                return(new Sub_Category_Response($"Error when updating sub category: {ex.Message}"));
            }
        }
 public void Update(Sub_category sub_Category)
 {
     context.Sub_Categories.Update(sub_Category);
 }
 public void Delete(Sub_category sub_Category)
 {
     context.Sub_Categories.Remove(sub_Category);
 }
 public async Task AddAsync(Sub_category sub_Category)
 {
     await context.Sub_Categories.AddAsync(sub_Category);
 }
Exemple #6
0
 public Sub_Category_Response(bool success, string message, Sub_category sub_Category) : base(success, message)
 {
     this.sub_Category = sub_Category;
 }
Exemple #7
0
 public Sub_Category_Response(Sub_category sub_Category) : this(true, string.Empty, sub_Category)
 {
 }