Ejemplo n.º 1
0
        // [ValidateAntiForgeryToken]
        public ActionResult Create(Store collection)
        {
            try
            {
                if (collection.State == null || collection.Address == null)
                {
                    return(Json(new { Message = "Input is required", status = "error", Success = false }));
                }

                // TODO: Add insert logic here
                if (collection.Id == Guid.Empty)
                {
                    var result = _IStoreServices.Add(collection);
                    return(Json(result == Guid.Empty ? new { Message = "An error Occured ;Ensure the store has not been previously added", status = "error", Success = false } : new { Message = "Record Added Succesfully", status = "success", Success = true }));
                }
                else
                {
                    var result = _IStoreServices.Edit(collection);
                    return(Json(!result ? new { Message = "An error Occured ;", status = "error", Success = false } : new { Message = "Record Updated Succesfully", status = "success", Success = true }));
                }
            }
            catch
            {
                return(Json(new { Message = "An error occured", status = "success", Success = true }));
            }
        }
Ejemplo n.º 2
0
 public ActionResult Stores(StoreVM store)
 {
     if (!IsAdmin())
     {
         return(Redirect("/"));
     }
     _storeService.Add(_storeMapper.ConvertFromStoreVM(store));
     return(Redirect("Stores"));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,Name,Address")] StoreVM store)
        {
            if (ModelState.IsValid)
            {
                _storeService.Add(StoreMappers.MapToModel(store));
                return(RedirectToAction("Index"));
            }

            return(View(store));
        }
Ejemplo n.º 4
0
        public IActionResult Add(Store store)
        {
            var result = _storeService.Add(store);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,CompanyId,Name,Address,City,Zip,Country,Longitude,Latitude")] Store store)
        {
            if (ModelState.IsValid)
            {
                store.Id = Guid.NewGuid();
                storeService.Add(store);
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyId = new SelectList(companyService.GetEntitiesByCondition(u => true).ToList(), "Id", "Name", store.CompanyId);
            return(View(store));
        }
Ejemplo n.º 6
0
        public IActionResult Post(StoreModel model)
        {
            var store = new Store
            {
                Name       = model.Name,
                Location   = new Domain.ValueObjects.Address(model.Location.Street, model.Location.City, model.Location.ZipCode),
                OpenedTime = model.OpenedTime,
                ClosedTime = model.ClosedTime,
            };

            _storeService.Add(store);
            return(Ok(model));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns>The id of the new record.</returns>
        private Guid Create()
        {
            // Arrange
            Store Store = Builder <Store> .CreateNew().With(s => s.Id = Guid.NewGuid())
                          .With(s => s.Address   = Address)
                          .With(s => s.State     = Address)
                          .With(s => s.Longitude = Faker.RandomNumber.Next())
                          .With(s => s.Latitude  = Faker.RandomNumber.Next())
                          .Build();

            // Act
            var storeId = _StoreService.Add(Store);

            // Assert
            Assert.AreNotEqual(Guid.Empty, Store.Id, "Creating new record does not return id");

            var sId = _StoreService.Add(Store);

            Assert.AreEqual(Guid.Empty, sId, "Creating new record does not return id");


            return(storeId);
        }
Ejemplo n.º 8
0
        public HttpResponseMessage Add(GenreModel model)
        {
            var genre = _mapper.Map <GenreModel, Genre>(model);

            try
            {
                _service.Add(genre);
            }
            catch (CoreServiceException ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 9
0
        /// <summary>
        ///根据url生成短链接id
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public string Generate(string url)
        {
            var         errorCount  = 0;
            var         postfix     = string.Empty;
            var         shortId     = string.Empty;
            ShortUrlMap shortUrlMap = null;

            // 违反唯一索引异常
            Func <DbUpdateException, bool> duplicateKeyPredict = ex =>
                                                                 ex.InnerException != null &&
                                                                 ex.InnerException.Message.Contains("duplicate key");

            Policy.Handle <DbUpdateException>(duplicateKeyPredict).Retry(2).Execute(() =>
            {
                // 在违反唯一索引的情况下,判断是否真实的重复提交
                if (errorCount == 1 && _storeService.Exist(shortId, url))
                {
                    shortUrlMap = new ShortUrlMap {
                        ShortId = shortId, LongUrl = url
                    };
                    return;
                }
                // hash冲突
                else
                {
                    // 计数错误次数
                    errorCount++;
                    // 追加自定义后缀(首次不需要追加,所以为空)
                    url += postfix;
                    // 首次完成后,开始追加真正的后缀
                    if (string.IsNullOrWhiteSpace(postfix))
                    {
                        postfix = GlobalConfig.CONFLICT_POSTFIX;
                    }

                    shortId     = _shortIdService.Generate(url);
                    shortUrlMap = new ShortUrlMap {
                        ShortId = shortId, LongUrl = url
                    };
                    _storeService.Add(shortUrlMap);
                }
            });

            return(shortUrlMap.ShortId);
        }
Ejemplo n.º 10
0
 private void CreateBtn_Click(object sender, EventArgs e)
 {
     try
     {
         Store store = new Store
         {
             Address     = CreateAddressTxt.Text,
             Name        = CreateStoreNameTxt.Text,
             PhoneNumber = CreatePhoneNumberTxt.Text
         };
         createMessage.CreateMessageBox(storeService.Add(store));
         CreateAddressTxt.Text     = "";
         CreateStoreNameTxt.Text   = "";
         CreatePhoneNumberTxt.Text = "";
         StoreGridViewGetAll();
     }
     catch (Exception)
     {
         MessageBox.Show("Tekrar deneyiniz...");
     }
 }
Ejemplo n.º 11
0
 public JsonResult Add(Store entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("IsDelete");
     if (ModelState.IsValid)
     {
         if (IStoreService.IsExits(x => x.Name == entity.Name && x.CityCode == entity.CityCode))
         {
             return(JResult(Core.Code.ErrorCode.store_city__namealready_exist, ""));
         }
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         var result = IStoreService.Add(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
Ejemplo n.º 12
0
        public ActionResult Create(StoreViewModel AVM)
        {
            try
            {
                // TODO: Add insert logic here
                Store A = new Store();
                A.Id                = AVM.Id;
                A.Adresse           = AVM.Adresse;
                A.Name              = AVM.Name;
                A.Tel               = AVM.Tel;
                A.Horaire_ouverture = AVM.Horaire_ouverture;
                A.Stock             = AVM.Stock;

                StoreService.Add(A);
                StoreService.Commit();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 13
0
        /// <inheritdoc />
        public async Task <bool> Login(LoginModel model)
        {
            var pathParams = new HttpPathParameters();

            pathParams.Add("login", -1);

            var settings = new HttpSettings(Url, null, pathParams, "Login");

            var body = new HttpBody <LoginModel>(model);

            var user = await _httpService.CreateWithResult <StorageUser, LoginModel>(settings, body);

            if (user == null)
            {
                return(false);
            }

            await _localStorageService.SetItemAsync("user", user);

            await _localStorageService.SetItemAsync("token", user.Token);

            _storeService.Add("user", user);
            return(true);
        }
Ejemplo n.º 14
0
 public IActionResult Post(StoreRequestModel storeRequestModel)
 {
     return(Ok(_storeService.Add(_mapper.Map <Stores>(storeRequestModel))));
 }
Ejemplo n.º 15
0
        public ActionResult Complete(CustomerViewModel model)
        {
            List <OrderDetails> list = new List <OrderDetails>();
            var basket = _BasketService.Get();

            if (ModelState.IsValid)
            {
                try
                {
                    Customers customer = new Customers();
                    customer.FirstName = model.Customers.FirstName;
                    customer.LastName  = model.Customers.LastName;
                    customer.Email     = model.Customers.Email;
                    customer.Address   = model.Customers.Address;
                    var Customer = _CustomerService.Add(customer);

                    Orders orders = new Orders();
                    orders.CustomerID = Customer.ID;
                    orders.Customer   = customer;
                    orders.OrderDate  = DateTime.Now;
                    orders.Total      = basket.Total;
                    orders.IsActive   = true;
                    _OrderService.Add(orders);

                    foreach (var item in basket.AddedProducts)
                    {
                        OrderDetails orderDetail = new OrderDetails();
                        orderDetail.ProductID = item.Product.ID;
                        orderDetail.Product   = _ProductService.Get(item.Product.ID);
                        orderDetail.OrderID   = orders.ID;
                        orderDetail.Order     = _OrderService.Get(orders.ID);
                        orderDetail.UnitPrice = item.Product.UnitPrice;
                        orderDetail.Quantity  = item.Quantity;
                        _OrderDetailService.Add(orderDetail);

                        list.Add(orderDetail);

                        Store store = new Store();
                        store.OrderDetailID = orderDetail.ID;
                        store.OrderDetail   = orderDetail;
                        store.IsDone        = false;
                        store.IsProcessing  = false;
                        _StoreService.Add(store);
                    }
                    Session["OrderDetails"] = list;
                    _BasketService.Set(null);

                    TempData.Add("complete", "complete");
                    TempData.Add("message", string.Format("Siparişiniz başarıyla depoya yollanmıştır."));
                    TempData.Add("status", "success");
                }
                catch (Exception ex)
                {
                    TempData.Add("message", string.Format("Bir hata oluştu : {0}", ex));
                    TempData.Add("status", "danger");
                }
            }
            else
            {
                TempData.Add("message", string.Format("Lütfen bütün bilgileri eksiksiz doldurunuz."));
                TempData.Add("status", "warning");
            }

            return(View());
        }
Ejemplo n.º 16
0
        public void Add(AuthorModel model)
        {
            var author = _mapper.Map <AuthorModel, Author>(model);

            _service.Add(author);
        }
Ejemplo n.º 17
0
        public object addStore(Dictionary <string, object> dicParas)
        {
            string errMsg         = string.Empty;
            string storeId        = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string companyname    = dicParas.ContainsKey("companyname") ? dicParas["companyname"].ToString() : string.Empty;
            string province       = dicParas.ContainsKey("province") ? dicParas["province"].ToString() : string.Empty;
            string address        = dicParas.ContainsKey("address") ? dicParas["address"].ToString() : string.Empty;
            string boss           = dicParas.ContainsKey("boss") ? dicParas["boss"].ToString() : string.Empty;
            string phone          = dicParas.ContainsKey("phone") ? dicParas["phone"].ToString() : string.Empty;
            string telphone       = dicParas.ContainsKey("telphone") ? dicParas["telphone"].ToString() : string.Empty;
            string clienttype     = dicParas.ContainsKey("clienttype") ? dicParas["clienttype"].ToString() : string.Empty;
            string power_due_date = dicParas.ContainsKey("power_due_date") ? dicParas["power_due_date"].ToString() : string.Empty;
            string note           = dicParas.ContainsKey("note") ? dicParas["note"].ToString() : string.Empty;
            string parentid       = dicParas.ContainsKey("parentid") ? dicParas["parentid"].ToString() : string.Empty;
            string developer      = dicParas.ContainsKey("developer") ? dicParas["developer"].ToString() : string.Empty;
            string store_password = dicParas.ContainsKey("store_password") ? dicParas["store_password"].ToString() : string.Empty;
            string wxfee          = dicParas.ContainsKey("wxfee") ? dicParas["wxfee"].ToString() : string.Empty;

            if (!CheckAddStore(dicParas, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
            }

            IStoreService storeService = BLLContainer.Resolve <IStoreService>();
            var           storeModel   = storeService.GetModels(p => p.id.ToString().Equals(storeId)).FirstOrDefault <t_store>();

            if (storeModel != null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店Id已存在"));
            }

            string  store_dbname = string.Empty;
            t_store store        = new t_store();

            store.id             = int.Parse(storeId);
            store.companyname    = companyname;
            store.province       = province;
            store.address        = address;
            store.boss           = boss;
            store.phone          = phone;
            store.telphone       = telphone;
            store.client_level   = "普通级";
            store.clienttype     = clienttype;
            store.createtime     = System.DateTime.Now;
            store.updatetime     = System.DateTime.Now;
            store.power_due_date = System.DateTime.Parse(System.DateTime.Parse(power_due_date).ToString("yyyy-MM-dd") + " 00:00:00");
            store.note           = note;
            store.parentid       = parentid;
            store.developer      = developer;
            store.store_password = store_password;
            store.store_dbname   = "xcgamedb" + storeId;
            store.wxfee          = Convert.ToDecimal(decimal.Parse(wxfee) / 1000);
            store.StoreType      = 0;
            store.State          = 1;
            store.Token          = "";

            if (storeService.Add(store))
            {
                List <StoreCacheModel> list  = StoreCache.GetStore();
                StoreCacheModel        model = new StoreCacheModel();
                model.StoreID       = int.Parse(storeId);
                model.StoreName     = companyname;
                model.StorePassword = store_password;
                model.StoreType     = Convert.ToInt32(store.StoreType);
                model.StoreDBName   = store_dbname;
                list.Add(model);
            }

            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
        }