Пример #1
0
        public async Task <ResponseModel> UpdateBranch(Branch objBranch)
        {
            try
            {
                using (GMSEntities gmsDbContext = new GMSEntities())
                {
                    objBranch.Modified = DateTime.Now;
                    gmsDbContext.Entry(objBranch).State = EntityState.Modified;
                    await gmsDbContext.SaveChangesAsync();

                    return(HelperClass.Response(true
                                                , GlobalDecleration._savedSuccesfully
                                                , null
                                                ));
                }
            }
            catch (Exception ex)
            {
                Print("UpdateBranch", ex.Message);
                return(HelperClass.Response(false
                                            , GlobalDecleration._internalServerError
                                            , null
                                            ));
            }
        }
        public async Task <ResponseModel> UpdateProductCategory(ProductCategory objProductCategory)
        {
            try
            {
                using (GMSEntities gmsDbContext = new GMSEntities())
                {
                    var checkProductCategory = gmsDbContext.ProductCategories.Where(cat => cat.Name == objProductCategory.Name && cat.Id != cat.Id).ToList();
                    if (checkProductCategory.Count() > 0)
                    {
                        return(HelperClass.Response(false
                                                    , GlobalDecleration._alreadyExits
                                                    , null
                                                    ));
                    }
                    else
                    {
                        gmsDbContext.Entry(objProductCategory).State = EntityState.Modified;
                        await gmsDbContext.SaveChangesAsync();

                        return(HelperClass.Response(true
                                                    , GlobalDecleration._savedSuccesfully
                                                    , null
                                                    ));
                    }
                }
            }
            catch (Exception ex)
            {
                Print("UpdateProductCategory", ex.Message);
                return(HelperClass.Response(false
                                            , GlobalDecleration._internalServerError
                                            , null
                                            ));
            }
        }
Пример #3
0
        public async Task <ResponseModel> CreateBranch(Branch objBranch)
        {
            try
            {
                using (GMSEntities gmsDbContext = new GMSEntities())
                {
                    if (objBranch.Id == 0)
                    {
                        objBranch.Id = gmsDbContext.Branches.DefaultIfEmpty().Max(p => p == null ? 0 : p.Id) + 1;
                    }
                    objBranch.Created  = DateTime.Now;
                    objBranch.Modified = DateTime.Now;
                    gmsDbContext.Entry(objBranch).State = System.Data.Entity.EntityState.Added;
                    await gmsDbContext.SaveChangesAsync();

                    return(HelperClass.Response(true
                                                , GlobalDecleration._savedSuccesfully
                                                , null
                                                ));
                }
            }
            catch (Exception ex)
            {
                Print("CreateBranch", ex.Message);
                return(HelperClass.Response(false
                                            , GlobalDecleration._internalServerError
                                            , null
                                            ));
            }
        }
 public async Task <ProductCategory> GetProductCategoryByCategoryId(long id)
 {
     try
     {
         using (GMSEntities gmsDbContext = new GMSEntities())
         {
             return(await gmsDbContext.ProductCategories.FindAsync(id));
         }
     }
     catch (Exception ex)
     {
         Print("GetProductCategoryByCategoryId", ex.Message);
         return(null);
     }
 }
 public async Task <List <ProductCategory> > GetAllProductCategory()
 {
     try
     {
         using (GMSEntities gmsDbContext = new GMSEntities())
         {
             var retLst = gmsDbContext.ProductCategories.ToList();
             return(retLst);
         }
     }
     catch (Exception ex)
     {
         Print("GetAllSubCategory", ex.Message);
         return(null);
     }
 }
Пример #6
0
 public async Task <ResponseModel> GetAllBranch()
 {
     try
     {
         using (GMSEntities gmsDbContext = new GMSEntities())
         {
             var retLst = gmsDbContext.Branches.OrderByDescending(x => x.Id).ToList();
             return(HelperClass.Response(true
                                         , GlobalDecleration._savedSuccesfully
                                         , retLst
                                         ));
         }
     }
     catch (Exception ex)
     {
         Print("GetAllBranch", ex.Message);
         return(HelperClass.Response(false
                                     , GlobalDecleration._internalServerError
                                     , null
                                     ));
     }
 }
        public async Task <ResponseModel> CreateProductCategory(ProductCategory objProductCategory)
        {
            try
            {
                using (GMSEntities gmsDbContext = new GMSEntities())
                {
                    gmsDbContext.Entry(objProductCategory).State = EntityState.Added;
                    await gmsDbContext.SaveChangesAsync();

                    return(HelperClass.Response(true
                                                , GlobalDecleration._savedSuccesfully
                                                , null
                                                ));
                }
            }
            catch (Exception ex)
            {
                Print("CreateProductCategory", ex.Message);
                return(HelperClass.Response(false
                                            , GlobalDecleration._internalServerError
                                            , null
                                            ));
            }
        }