Ejemplo n.º 1
0
        public long UpdateStore(tblStoreAccount storeaccount)
        {
            long result = 0;

            try
            {
                storeaccount.CreatedDate = DateTime.Now;
                using (var db = ContextFactory.UsTransportEntities())
                {
                    var _temp = db.tblStoreAccounts.Where(x => x.id == storeaccount.id).FirstOrDefault();
                    if (_temp != null)
                    {
                        db.Entry(_temp).CurrentValues.SetValues(storeaccount);
                        if (db.SaveChanges() > 0)
                        {
                            result = _temp.id;
                        }
                    }
                    result = storeaccount.id;
                }
            }
            catch (Exception ex)
            {
                string e = ex.Message;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult InsertStore(tblStoreAccount storeModel)
        {
            var result = new Models.CustomJsonResult();

            try
            {
                result.Result = storeService.InsertStore(storeModel);
                if (int.Parse(result.Result.ToString()) > 0)
                {
                    long UserID = userService.CreateUser(storeModel.Email, storeModel.Password, storeModel.FullName);
                    if (UserID > 0)
                    {
                        roleService.UpdateRoleUser(UserID, 4);
                        result.Message = "Create new Store successly! Please wait for system checkin and active your store";
                    }
                }
                if (int.Parse(result.Result.ToString()) < 1)
                {
                    result.Message = "Has error, please try again!";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult DetailStore(int id = -1)
        {
            StoreModel storeModel = new StoreModel();
            int        userID     = -1;

            if (int.TryParse(Session[Constant.SessionUserID].ToString(), out userID))
            {
                var lstRoleId = _userService.GetLstRoleIdByUserId(int.Parse(Session[Constant.SessionUserID].ToString()));
                if (lstRoleId != null && lstRoleId.Any())
                {
                    if (lstRoleId.Count == 1 && lstRoleId.Contains(RoleEnum.Store))
                    {
                        tblStoreAccount storeInfo = (tblStoreAccount)Session[Constant.SessionStoreAccountInfo];
                        if (storeInfo != null)
                        {
                            ViewBag.UpdateYourStore = true;
                            storeModel.StoreAccount = _storeService.SelectStoreByID(storeInfo.id);;
                            storeModel.UserRole     = roleService.Select(storeModel.StoreAccount.Email);
                        }
                    }
                    if (lstRoleId.Contains(RoleEnum.Admin))
                    {
                        ViewBag.IsAdmin = true;
                    }
                }
            }
            if (id != -1)
            {
                storeModel.StoreAccount = _storeService.SelectStoreByID(id);
                storeModel.UserRole     = roleService.Select(storeModel.StoreAccount.Email);
            }
            return(View(storeModel));
        }
Ejemplo n.º 4
0
        public long InsertStore(tblStoreAccount storeaccount)
        {
            long result = 0;

            try
            {
                storeaccount.CreatedDate = DateTime.Now;
                storeaccount.IsActive    = true;
                using (var db = ContextFactory.UsTransportEntities())
                {
                    if (db.tblStoreAccounts.FirstOrDefault(s => s.Email.ToLower() == storeaccount.Email.ToLower()) != null)
                    {
                        return(-1);
                    }
                    db.tblStoreAccounts.Add(storeaccount);
                    db.SaveChanges();
                    result = storeaccount.id;
                }
            }
            catch (Exception ex)
            {
                SELog.WriteLog("StoreServices => InsertStore", ex);
            }
            return(result);
        }
Ejemplo n.º 5
0
        public long UpdateStore(tblStoreAccount storeaccount)
        {
            long result = 0;

            try
            {
                storeaccount.CreatedDate = DateTime.Now;
                using (var db = ContextFactory.UsTransportEntities())
                {
                    var _temp = db.tblStoreAccounts.FirstOrDefault(x => x.id == storeaccount.id);
                    if (storeaccount.Status == null)
                    {
                        storeaccount.Status   = _temp.Status;
                        storeaccount.Password = _temp.Password;
                    }
                    if (_temp != null)
                    {
                        db.Entry(_temp).CurrentValues.SetValues(storeaccount);
                        if (db.SaveChanges() > 0)
                        {
                            result = _temp.id;
                        }
                    }
                    result = storeaccount.id;
                }
            }
            catch (Exception ex)
            {
                SELog.WriteLog("StoreServices => UpdateStore", ex);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public tblStoreAccount SelectStoreByUserName(string UserName)
        {
            tblStoreAccount _item = new tblStoreAccount();

            try
            {
                using (var db = ContextFactory.UsTransportEntities())
                {
                    _item = db.tblStoreAccounts.Where(x => x.Email == UserName.Trim()).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                string e = ex.Message;
            }
            return(_item);
        }
Ejemplo n.º 7
0
        public tblStoreAccount SelectStoreByID(int id)
        {
            tblStoreAccount _item = new tblStoreAccount();

            try
            {
                using (var db = ContextFactory.UsTransportEntities())
                {
                    _item = db.tblStoreAccounts.Where(x => x.id == id).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                string e = ex.Message;
            }
            return(_item);
        }
Ejemplo n.º 8
0
        public tblStoreAccount SelectStoreByID(int id)
        {
            tblStoreAccount _item = new tblStoreAccount();

            try
            {
                using (var db = ContextFactory.UsTransportEntities())
                {
                    _item = db.tblStoreAccounts.Where(x => x.id == id).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                SELog.WriteLog("StoreServices => SelectStoreByID", ex);
            }
            return(_item);
        }
Ejemplo n.º 9
0
        public long InsertStore(tblStoreAccount storeaccount)
        {
            long result = 0;

            try
            {
                storeaccount.CreatedDate = DateTime.Now;
                storeaccount.Status      = 0;
                using (var db = ContextFactory.UsTransportEntities())
                {
                    db.tblStoreAccounts.Add(storeaccount);
                    db.SaveChanges();
                    result = storeaccount.id;
                }
            }
            catch (Exception ex)
            {
                string e = ex.Message;
            }
            return(result);
        }