예제 #1
0
        public async Task <IActionResult> AddShop(ShopEntity entity)
        {
            if (ModelState.IsValid)
            {
                var data = await shopService.Add(entity, GetUserSession().user_id);

                return(Json(data));
            }
            return(Json(ParrNoPass()));
        }
예제 #2
0
        private void AddShop()
        {
            Shop shop = new Shop();

            shop.ShopName    = txtShopName.Text;
            shop.PhoneNumber = txtShopPhoneNumber.Text;
            shop.Email       = txtShopEmail.Text;
            shop.Address     = rtxtShopAddress.Text;

            _shopManager.Add(shop);
            MessageBox.Show(ShopMessage.AddMessage());
        }
예제 #3
0
        public HttpResponseMessage Create(HttpRequestMessage request, Shop shop)
        {
            Shop modelShop = null;

            try
            {
                var tenTaiKhoan1 = shop.TenShop.ToLower();
                var tenTaiKhoan2 = _shopService.ThayDoiChuoi(tenTaiKhoan1);
                var tenTaiKhoan3 = tenTaiKhoan2.Replace(" ", "");
                var pass         = shop.SDT.Substring(shop.SDT.Length == 11 ? 7 : 6);

                var taikhoan = new TaiKhoan
                {
                    UserName  = tenTaiKhoan3,
                    Pass      = pass,
                    IdQuyen   = 4,// quyen shop
                    TrangThai = true,
                };
                var taiKhoan = _taiKhoanService.Add(taikhoan);
                _shopService.SaveChange();
                if (taiKhoan.IdTaiKhoan != 0)
                {
                    shop.IdTaiKhoan = taikhoan.IdTaiKhoan;
                    shop.PheDuyet   = false;
                    if (shop.DongYChinhSach == null)
                    {
                        shop.DongYChinhSach = false;
                    }
                    modelShop = _shopService.Add(shop);
                    _shopService.SaveChange();
                    if (modelShop != null)
                    {
                        Message = "Tạo mới shop và tài khoản thành công thành công";
                        _taiKhoanService.SaveChange();
                    }
                }
                if (modelShop != null)
                {
                    Message = "Tạo mới shop thành công";
                    _shopService.SaveChange();
                }
                else
                {
                    throw new DbEntityValidationException("tạo mới shop không thành công");
                }
            }
            catch (DbEntityValidationException ex)
            {
                LogException(ex);
            }
            return(GetResponseMessage(IsSuccess, Message, 1, modelShop));
        }
예제 #4
0
 public IActionResult Create([FromForm] Shop shop)
 {
     try
     {
         shop.ShopTranslates = JsonSerializer.Deserialize <ICollection <ShopTranslate> >(shop.Translates);
         if (!ModelState.IsValid)
         {
             return(StatusCode(StatusCodes.Status500InternalServerError, new Response
             {
                 Status = "Error",
                 Messages = new Message[] {
                     new Message {
                         Lang_id = 1,
                         MessageLang = "Model state isn't valid!"
                     },
                     new Message {
                         Lang_id = 2,
                         MessageLang = "Состояние модели недействительно!"
                     },
                     new Message {
                         Lang_id = 3,
                         MessageLang = "Model vəziyyəti etibarsızdır!"
                     }
                 }
             }));
         }
         _shopContext.Add(shop);
         foreach (ShopTranslate item in shop.ShopTranslates)
         {
             item.ShopId = shop.Id;
             _shopTranslateContext.Add(item);
         }
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
예제 #5
0
        public IActionResult Post([FromBody] Shop body)
        {
            var entity = _manager.Add(body);

            return(ResponseJson(entity));
        }