Beispiel #1
0
        private static ResultModel <string> _validationInvoice(InvoiceModel param)
        {
            end.StatusCode = (int)HttpStatusCode.NotAcceptable;
            if (param == null)
            {
                end.StatusMessage = "Parameter is empty";
                return(end);
            }
            if (string.IsNullOrEmpty(param.ID))
            {
                end.StatusMessage = "No Invoice is required";
                return(end);
            }
            if (!param.TransactionDate.HasValue)
            {
                end.StatusMessage = "Transaction Date is required";
                return(end);
            }
            if (!param.UsersID.HasValue)
            {
                end.StatusMessage = "Customer is required";
                return(end);
            }
            if (param.Items.Count < 1)
            {
                end.StatusMessage = "List Product is required";
                return(end);
            }
            var user = ManageUser.GetById(param.UsersID.Value);

            if (user == null)
            {
                end.StatusMessage = "Customer is not found";
                return(end);
            }
            var No = ManageInvoice.GetById(param.ID);

            if (No != null)
            {
                param.ID = GenerateInvoice().Value;
            }
            foreach (ListInvoiceModel item in param.Items)
            {
                var Product = ManageCatalogue.GetById(item.CatalogueID);
                if (Product == null)
                {
                    end.StatusMessage = "Product is not found";
                    return(end);
                }
                if (Product.Qty < item.Qty)
                {
                    end.StatusMessage = "Quantity Product smaller than Request";
                    return(end);
                }
            }
            end.StatusCode = (int)HttpStatusCode.OK;
            return(end);
        }
Beispiel #2
0
        public ResultModel <User> GetById(int id)
        {
            ResultModel <User> res = new ResultModel <User>();

            var ret = ManageUser.GetById(id);

            res.StatusCode = (int)HttpStatusCode.NotFound;
            if (ret != null)
            {
                res.StatusCode = (int)HttpStatusCode.OK; res.Value = ret;
            }
            return(res);
        }
Beispiel #3
0
        public static ResultModel <EFResponse> DeleteUsers(int ID)
        {
            res.StatusCode = (int)HttpStatusCode.NotFound;
            var User = ManageUser.GetById(ID);

            if (User != null)
            {
                res.StatusCode = (int)HttpStatusCode.Found;
                var ret = ManageUser.Delete(User);
                if (ret.Success)
                {
                    res.StatusCode = (int)HttpStatusCode.OK; res.Value = ret;
                }
            }
            return(res);
        }
Beispiel #4
0
        public static ResultModel <EFResponse> UpdateUsers(User param)
        {
            res.StatusCode = (int)HttpStatusCode.NotFound;
            var User = ManageUser.GetById(param.ID);

            if (User != null)
            {
                res.StatusCode = (int)HttpStatusCode.Found;
                var ret = ManageUser.Update(param);
                if (ret.Success)
                {
                    res.StatusCode = (int)HttpStatusCode.OK; res.Value = ret;
                }
            }
            return(res);
        }