Esempio n. 1
0
        public static Helpers.Common.Result ReturnModelMessage(CreateOrderDTO insertOrder)
        {
            var result = new Helpers.Common.Result();

            if (insertOrder.Name == "string".ToLower())
            {
                result.ModelMessageList.Add(o => o.Name, " Please Enter the Name", false);
                return(result);
            }
            if (insertOrder.costPerItem == 0)
            {
                result.ModelMessageList.Add(o => o.Payment, " Please Enter the CostPer item, Even though it takes $20/Quantity", false);
                return(result);
            }
            else if (insertOrder.Quantity == 0)
            {
                result.ModelMessageList.Add(o => o.Quantity, "Please Enter the Quantity", false);
                return(result);
            }
            else if (insertOrder.Shipping.ShippingType == "string".ToLower())
            {
                result.ModelMessageList.Add(o => o.Shipping, " Please enter ShippingType", false);
                return(result);
            }
            else
            {
                result.ModelMessageList.Add(o => o.Name, " Fields validation are done", true);
                return(result);
            }
        }
Esempio n. 2
0
        public Helpers.Common.Result Add(Brand b)
        {
            var result = new Helpers.Common.Result();

            try
            {
                if (!Helpers.CommonHelper.CheckIsNull(b.Name))
                {
                    conn.Insert(b);
                    result.Status  = true;
                    result.Message = "Save successfully.";
                }
                else
                {
                    result.Status  = false;
                    result.Message = "Name is required.";
                }
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(result);
        }
Esempio n. 3
0
        public Helpers.Common.Result Edit(Brand b)
        {
            var result = new Helpers.Common.Result();

            try
            {
                conn.Update(b);
                result.Status  = true;
                result.Message = "Update successfully.";
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(result);
        }
Esempio n. 4
0
        public Helpers.Common.Result Delete(Brand b)
        {
            var result = new Helpers.Common.Result();

            try
            {
                conn.Table <Brand>().Delete(e => e.Id == b.Id);
                result.Status  = true;
                result.Message = "Delete successfully.";
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(result);
        }
Esempio n. 5
0
        public Helpers.Common.Result UpdateBulkOrders(List <CompositeObject> OrderIds)
        {
            var result = new Helpers.Common.Result();
            var Orders = _OrdersContext.Orders.Where(s => OrderIds.Select(v => v.ListOutToUpdateOrdersID).Contains(s.Id))
                         .Include(Payment => Payment.Payment)
                         .Include(Ship => Ship.Shipping)
                         .ToList();

            if (Orders.Count() != OrderIds.Count())
            {
                result.ModelMessageList.Add(o => o.Name, "OrderIds are not found in DataBase", false);
                return(result);
            }
            List <Orders> OrdersList = new List <Orders>();

            for (int i = 0; i < OrderIds.Count(); i++)
            {
                var Order = Orders.Where(s => s.Id == OrderIds[i].ListOutToUpdateOrdersID)
                            .FirstOrDefault();

                if (OrderIds[i].Status == "string".ToLower())
                {
                    result.ModelMessageList.Add(o => o.Name, " Please Enter the Status", false);
                    return(result);
                }

                Order.Status       = OrderIds[i].Status;
                Order.ModifiedDate = DateTimeOffset.Now;
                OrdersList.Add(Order);
            }
            _OrdersContext.Orders.UpdateRange(OrdersList);
            if (Save())
            {
                result.ModelMessageList.Add(o => o.Name, "Orders status Updated to Delivered", true);
                return(result);
            }
            else
            {
                result.ModelMessageList.Add(o => o.Name, "Orders Updated Successfully", false);
                return(result);
            }
        }
Esempio n. 6
0
        public Helpers.Common.Result GetOrder(int Id)
        {
            var result = new Helpers.Common.Result();
            var order  = _OrdersContext.Orders.Where(s => s.Id == Id)
                         .Include(Payment => Payment.Payment)
                         .Include(Ship => Ship.Shipping)
                         .FirstOrDefault();

            if (order == null)
            {
                _Logger.LogWarning($"No Record found with that ID {Id}");
                result.ModelMessageList.Add(o => o.Name, "No Record found with that ID", false);
                return(result);
            }
            else
            {
                var Maporder = _mapper.Map <OrdersDTO>(order);
                result.OrderDTO = Maporder;
                return(result);
            }
        }
Esempio n. 7
0
        public Helpers.Common.Result CreateBulkOrder(List <CreateOrderDTO> insertOrders)
        {
            var result = new Helpers.Common.Result();

            foreach (var order in insertOrders)
            {
                result = OrderManager.ReturnModelMessage(order);
                if (result.ModelMessageList.Any(s => s.IsSuccess))
                {
                    result = new Helpers.Common.Result();
                }
                else
                {
                    return(result);
                }
            }
            var OrdersList = OrderManager.GetOrdersToInsert(insertOrders);

            var SumPayment = insertOrders.Sum(v => v.Payment.Sum(s => s.Paymentamount));   //.Payment.Sum(s => s.Paymentamount);
            var TotalordersActualPayment = OrdersList.Sum(v => v.Total);

            if (SumPayment == 0 || SumPayment != TotalordersActualPayment)
            {
                result.ModelMessageList.Add(o => o.Name, " The Price for Each Order is $20/Quantity, Tax = 0.6%, Shipping Charges = 0.7% the Sum of orders should be: " + TotalordersActualPayment + ".", false);
                return(result);
            }

            _OrdersContext.Orders.AddRange(OrdersList);
            //_OrdersContext.BulkInsert(OrdersList);
            if (Save())
            {
                result.ModelMessageList.Add(o => o.Name, "Records Inserted Successfully", true);
                return(result);
            }
            else
            {
                result.ModelMessageList.Add(o => o.Name, "Records Insertion failed", false);
                return(result);
            }
        }
        public Helpers.Common.Result Add(Product b)
        {
            var result = new Helpers.Common.Result();

            try
            {
                result.Status = true;
                if (b.BrandId == null || b.BrandId == 0)
                {
                    result.Status  = false;
                    result.Message = result.Message + "Brand is required.";
                }

                if (b.CategoryId == null || b.CategoryId == 0)
                {
                    result.Status  = false;
                    result.Message = result.Message + "\nCategory is required.";
                }

                if (Helpers.CommonHelper.CheckIsNull(b.Name))
                {
                    result.Status  = false;
                    result.Message = result.Message + "\nName is required.";
                }

                if (result.Status)
                {
                    conn.Insert(b);
                    result.Status  = true;
                    result.Message = "Save successfully.";
                }
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(result);
        }
Esempio n. 9
0
        public Helpers.Common.Result DeleteOrder(int Id)
        {
            var result = new Helpers.Common.Result();
            var order  = _OrdersContext.Orders.Where(s => s.Id == Id)
                         .Include(Payment => Payment.Payment)
                         .Include(Ship => Ship.Shipping)
                         .FirstOrDefault();

            if (order != null)
            {
                _OrdersContext.Orders.Remove(order);
                Save();
                result.ModelMessageList.Add(o => o.Name, "Record Deleted Successfully", true);
                return(result);
            }
            else
            {
                _Logger.LogWarning($"No Record found with that ID {Id}");
                result.ModelMessageList.Add(o => o.Name, "No Record found with that ID", false);
                return(result);
            }
        }
Esempio n. 10
0
        public Helpers.Common.Result CreateOrder(CreateOrderDTO insertOrder)
        {
            var result = new Helpers.Common.Result();

            var sumpayment = insertOrder.Payment.Sum(s => s.Paymentamount);

            result = OrderManager.ReturnModelMessage(insertOrder);
            if (result.ModelMessageList.Any(s => s.IsSuccess))
            {
                result = new Helpers.Common.Result();
            }
            else
            {
                return(result);
            }

            var NewOrder = OrderManager.SingleOrder(insertOrder);

            if (sumpayment == 0 || sumpayment != NewOrder.Total)
            {
                result.ModelMessageList.Add(o => o.Name, " The Price for Each Order is $20/Quantity, Tax = 0.6%, Shipping Charges = 0.7% the total should be: " + NewOrder.Total + ".", false);
                return(result);
            }

            _OrdersContext.Orders.Add(NewOrder);

            if (Save())
            {
                result.ModelMessageList.Add(o => o.Name, "Order Inserted Successfully", true);
                return(result);
            }
            else
            {
                result.ModelMessageList.Add(o => o.Name, "Order Not Inserted", false);
                return(result);
            }
        }