Example #1
0
        public ActionResult AddStore(VM_Store store)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    tblStore aStore = new tblStore();
                    aStore.StoreName       = store.StoreName;
                    aStore.WorkShopId      = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString());
                    aStore.CreatedBy       = SessionManger.LoggedInUser(Session);
                    aStore.CreatedDateTime = DateTime.Now;
                    aStore.EditedBy        = null;
                    aStore.EditedDateTime  = null;

                    unitOfWork.StoreRepository.Insert(aStore);
                    unitOfWork.Save();

                    return(Json(new { success = true, successMessage = "Store Save Successfully" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = false, errorMessage = "Store not Save" }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
 public static Store LoadbyId(Guid id)
 {
     try
     {
         using (GroceryGetterEntities dc = new GroceryGetterEntities())
         {
             tblStore tblStore = dc.tblStores.FirstOrDefault(c => c.Id == id);
             if (tblStore != null)
             {
                 Store store = new Store
                 {
                     Id    = tblStore.Id,
                     Title = tblStore.Title
                 };
                 return(store);
             }
             else
             {
                 throw new Exception("Row was not found!!!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string StoreDelete(int StoreID)
 {
     try
     {
         tblStore store = db.tblStores.Single(x => x.StoreID == StoreID);
         db.tblStores.Remove(store);
         db.SaveChanges();
         return("Store Deleted Successfully");
     }
     catch (Exception ex)
     {
         return("Store Deleting faild" + ex);
     }
 }
        public string StoreUpdate(Store objStore)
        {
            try
            {
                tblStore Store = db.tblStores.Single(x => x.StoreID == objStore.StoreID);
                Store.StoreName     = objStore.StoreName;
                Store.StoreMobileNo = objStore.StoreMobileNo;
                Store.StoreAddress  = objStore.StoreAddress;
                Store.StoreEmailId  = objStore.StoreEmailId;
                Store.StoreStatus   = objStore.StoreStatus;
                db.SaveChanges();

                return("Store Updated Successfully");
            }
            catch (Exception ex)
            {
                return("Store Update faild" + ex);
            }
        }
Example #5
0
 public static bool Insert(Store store)
 {
     try
     {
         using (GroceryGetterEntities dc = new GroceryGetterEntities())
         {
             tblStore newrow = new tblStore();
             newrow.Id    = Guid.NewGuid();
             newrow.Title = store.Title;
             dc.tblStores.Add(newrow);
             dc.SaveChanges();
             store.Id = newrow.Id;
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public string StoreInsert(Store objStore)
        {
            try
            {
                tblStore Store = new tblStore();
                Store.StoreName     = objStore.StoreName;
                Store.StoreMobileNo = objStore.StoreMobileNo;
                Store.StoreAddress  = objStore.StoreAddress;
                Store.StoreEmailId  = objStore.StoreEmailId;
                Store.StoreStatus   = objStore.StoreStatus;

                db.tblStores.Add(Store);
                db.SaveChanges();
                return("Store Inserted Successfully");
            }
            catch (Exception ex)
            {
                return("Store Inserting faild" + ex);
            }
        }
Example #7
0
        /// <summary>
        /// Save Store
        /// </summary>
        /// <param name="Store"></param>

        /// <returns></returns>
        public bool SaveStores(StoreViewModel customerViewModel)
        {
            bool status = false;

            tblStore stores = new tblStore();

            Mapper.Map(customerViewModel, stores);

            stores.IsActive     = true;
            stores.CreatedDate  = DateTime.Now;
            stores.ModifiedDate = DateTime.Now;
            stores.CreatedBy    = "101";
            stores.ModifiedBy   = "101";
            _Context.tblStores.Add(stores);
            _Context.Configuration.ValidateOnSaveEnabled = true;
            _Context.SaveChanges();
            status = true;


            return(status);
            // for new users
        }
Example #8
0
 public static int Delete(Guid id)
 {
     try
     {
         using (GroceryGetterEntities dc = new GroceryGetterEntities())
         {
             tblStore deleterow = dc.tblStores.FirstOrDefault(c => c.Id == id);
             if (deleterow != null)
             {
                 dc.tblStores.Remove(deleterow);
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Row was not found!!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #9
0
        public static int Update(Store store)
        {
            try
            {
                using (GroceryGetterEntities dc = new GroceryGetterEntities())
                {
                    tblStore updatedrow = dc.tblStores.Where(c => c.Id == store.Id).FirstOrDefault();
                    if (updatedrow != null)
                    {
                        updatedrow.Title = store.Title;

                        return(dc.SaveChanges());
                    }
                    else
                    {
                        throw new Exception("Row was not found!");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #10
0
        /// <summary>
        /// Get Store detail by Id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public StoreViewModel GetStoresDetailsById(long Id)
        {
            tblStore store = _Context.tblStores.Where(x => x.id == Id).FirstOrDefault();

            return(Mapper.Map(store, new StoreViewModel()));
        }