示例#1
0
        public IHttpActionResult Post([FromBody] SaveMemberImageDTO model)
        {
            short memberId = _dataAccessProvider.GetMemberId(AuthKey);

            if (memberId != -1)
            {
                if (ModelState.IsValid)
                {
                    var result = _dataAccessProvider.SaveMemberImage(memberId, model.ImageName, model.ImagePath, memberId, model.IPAddress);
                    if (result.Length == 0)
                    {
                        return(Ok());
                    }
                    return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError(Common.Common.ReplaceError(result)))));
                }
                return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError("Form Error"))));
            }
            return(Unauthorized());
        }
        public IHttpActionResult Post([FromBody] SaveProductDTO model)
        {
            short memberId = _dataAccessProvider.GetMemberId(AuthKey);

            if (memberId != -1)
            {
                if (ModelState.IsValid)
                {
                    short  productId;
                    string result = _dataAccessProvider.SaveProduct(out productId, model.ProductGroup, model.StartDate, model.EndDate, model.Subject, model.Content,
                                                                    model.OnHandStock, model.StandardPrice, model.MembershipPrice, memberId, model.IPAddress);
                    if (result.Length == 0)
                    {
                        return(Ok(new { ProductId = productId }));
                    }
                    return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError(Common.Common.ReplaceError(result)))));
                }
                return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError("Form Error"))));
            }
            return(Unauthorized());
        }
        public IHttpActionResult Post(Sales item)
        {
            short memberId = _dataAccessProvider.GetMemberId(AuthKey);

            if (item != null)
            {
                if (item.Payment != null && item.Payment.Paid == true)
                {
                    string strInvNo = "";
                    string result   = _dataAccessProvider.SaveSalesMaster(out strInvNo, memberId, $"{item.OrderPerson?.FirstName ?? ""} {item.OrderPerson?.LastName ?? ""}", item.OrderPerson?.Building ?? "",
                                                                          item.OrderPerson?.Street ?? "", item.OrderPerson?.City ?? "", item.OrderPerson?.State ?? "", item.OrderPerson?.Zip ?? "", item.OrderPerson?.Email ?? "",
                                                                          item.OrderPerson?.ContactPhone ?? "", memberId, item.IpAddress ?? "");
                    if (result.Length == 0 && strInvNo.Length > 0)
                    {
                        for (short i = 0; i < item.CartProduct.Count; i++)
                        {
                            string result2 = "";
                            if (memberId != -1)
                            {
                                result2 = _dataAccessProvider.SaveSalesDetail(strInvNo, i, item.CartProduct[i].ProductID, item.CartProduct[i].Total, item.CartProduct[i].MembershipPrice, item.CartProduct[i].StandardPrice);
                            }
                            else
                            {
                                result2 = _dataAccessProvider.SaveSalesDetail(strInvNo, i, item.CartProduct[i].ProductID, 1, item.CartProduct[i].StandardPrice, item.CartProduct[i].MembershipPrice);
                            }
                            if (result2.Length > 0)
                            {
                                return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError(Common.Common.ReplaceError(result2)))));
                            }
                        }
                        return(Ok());
                    }
                    return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError(Common.Common.ReplaceError(result)))));
                }
                return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError("Not Paid"))));
            }
            return(new ResponseMessageResult(Request.CreateErrorResponse((HttpStatusCode)422, new HttpError("Json Error"))));
        }