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
                                            ));
            }
        }
Esempio n. 2
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
                                            ));
            }
        }
Esempio n. 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 <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
                                            ));
            }
        }