Пример #1
0
        public async Task <IHttpActionResult> Post([FromBody] UserToken model)
        {
            bool result = true;

            if (ModelState.IsValid)
            {
                await Task.Run(() => result = _iBaseBusiness.Insert(model));

                if (result)
                {
                    return(Ok());
                }
                return(NotFound());
            }
            return(BadRequest(ModelState));
        }
Пример #2
0
        // POST: api/User
        public string Post([FromBody] User user)
        {
            var ret = string.Empty;

            var result = (new UserValidator()).Validate(user);

            if (user != null && result.IsValid)
            {
                userBusiness.Insert(user);
            }
            else
            {
                ret = String.Join("<br>", result.Errors);
            }

            return(ret);
        }
Пример #3
0
        /*
         * // GET: api/User/5
         * public Product Get(int id)
         * {
         *  return productBusiness.SelectSingle(e => e.Id == id);
         * }
         */
        // POST: api/User
        public string Post([FromBody] Product product)
        {
            var ret = string.Empty;

            var result = (new ProductValidator()).Validate(product);

            if (product != null && result.IsValid)
            {
                productBusiness.Insert(product);
            }
            else
            {
                ret = String.Join("<br>", result.Errors);
            }

            return(ret);
        }
Пример #4
0
        // POST: api/User
        public string Post([FromBody] Store store)
        {
            var ret = string.Empty;

            var result = (new StoreValidator()).Validate(store);

            if (store != null && result.IsValid)
            {
                storeBusiness.Insert(store);
            }
            else
            {
                ret = String.Join("<br>", result.Errors);
            }

            return(ret);
        }
Пример #5
0
        // POST: api/User
        public string Post([FromBody] Feedback feedback)
        {
            var ret = string.Empty;

            var result = (new FeedbackValidator()).Validate(feedback);

            if (feedback != null && result.IsValid)
            {
                feedbackBusiness.Insert(feedback);
            }
            else
            {
                ret = "Error:" + String.Join("<br>", result.Errors);
            }

            return(ret);
        }
Пример #6
0
        // POST: api/User
        //public string Post([FromBody]int userid, [FromBody]List<SaleItem> itens)
        public string Post(FormDataCollection Data)
        {
            var ret = string.Empty;

            JavaScriptSerializer ser   = new JavaScriptSerializer();
            List <SaleItem>      itens = ser.Deserialize <List <SaleItem> >(Data.Get("itens"));

            int IdStore = 0;

            foreach (SaleItem item in itens)
            {
                var aux = productBusiness.SelectSingle(e => e.Id == item.IdProduct);
                item.Item  = null; //
                item.Price = aux.Price;
                IdStore    = aux.IdStore;
            }

            Sale vend = new Sale();

            vend.IdUser    = Convert.ToInt32(Data.Get("userid"));
            vend.Items     = itens;
            vend.IdStore   = IdStore;
            vend.Paid      = true;
            vend.Delivered = false;
            vend.Ticket    = RandomString(20);

            var result = (new SaleValidator()).Validate(vend);

            if (vend != null && result.IsValid)
            {
                saleBusiness.Insert(vend);
            }
            else
            {
                ret = String.Join("<br>", result.Errors);
            }

            return(ret);
        }