Esempio n. 1
0
        public ActionResult postCustomerVisitedClaim([FromBody] AgentCustomerVisitedClaimView agentCustomersVisitedClaims)
        {
            string st = "";

            try
            {
                int claimId = _context.ShopVisitedClaimTypes.Where(obj => obj.ClaimType == agentCustomersVisitedClaims.ClaimType).FirstOrDefault().Id;
                AgentCustomersVisitedClaims new_agentCustomersVisitedClaims = new AgentCustomersVisitedClaims();  //current date is default value of claimdate
                new_agentCustomersVisitedClaims.AgentOrderStatusId = agentCustomersVisitedClaims.AgentOrderStatusId;
                new_agentCustomersVisitedClaims.VisitedClaimTypeId = claimId;
                new_agentCustomersVisitedClaims.ClaimDate          = agentCustomersVisitedClaims.ClaimDate;
                _context.AgentCustomersVisitedClaims.Add(new_agentCustomersVisitedClaims);
                _context.SaveChanges();
                st = "SaveSuccess";
            }
            catch (Exception ex)
            {
                st = ex.Message;
            }
            AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(agentCustomersVisitedClaims.AgentOrderStatusId);

            agentOrderStatus.AgentTargetStatusId = 2;  //productive target status(mean booking->(orderstatus:1)  success)
            _context.AgentOrderStatus.Update(agentOrderStatus);
            _context.SaveChangesAsync();


            return(Ok(new { CustomerVisitedClaimStatus = "ClaimSaveSuccess" }));
        }
Esempio n. 2
0
        public async Task <ActionResult <CartProductView> > updateOrderProducts([FromBody]  PlaceOrderView orderProductsList)
        {
            foreach (CartProductView orderProducts in orderProductsList.ListOrderProduct)
            {
                Inventory previousInven = _context.Inventory.Find(orderProducts.InventoryId);
                previousInven.Id = orderProducts.InventoryId;

                previousInven.TotalPacket_Cartoon += orderProducts.QTY;
                _context.Inventory.Update(previousInven);

                OrderProducts beingUpdate_orderProducts = _context.OrderProducts.Find(orderProducts.Id);
                beingUpdate_orderProducts.Id        = orderProducts.Id;
                beingUpdate_orderProducts.QTY      -= orderProducts.QTY;
                beingUpdate_orderProducts.OrderDate = System.DateTime.Parse(orderProducts.OrderDate);


                await _context.SaveChangesAsync();
            }
            AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(orderProductsList.ListOrderProduct[0].AgentOrderStatusId);

            agentOrderStatus.AgentTargetStatusId = 3;
            agentOrderStatus.OrderStatusId       = 2; //productive target status(mean booking->(orderstatus:1)  success)

            _context.AgentOrderStatus.Update(agentOrderStatus);
            await _context.SaveChangesAsync();

            return(Ok(new { returnCustomerOrder = "ReturnSuccess" }));
            //  return CreatedAtAction("GetOrderProducts", new { id = orderProducts.Id }, orderProducts);
        }
Esempio n. 3
0
        [HttpPut("{agentOrderStatusId}")] //for delivery of order
                                          // [Route("UpdateOrderStatus")]
        public async Task <IActionResult> PutOrderProducts(int agentOrderStatusId)
        {
            AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(agentOrderStatusId);

            agentOrderStatus.AgentTargetStatusId = 3;  //productive target status(mean booking->(orderstatus:1)  success)
            _context.AgentOrderStatus.Update(agentOrderStatus);
            await _context.SaveChangesAsync();

            return(Ok(new { OrderDeliverStatus = "DeliverSuccess" }));
        }
        public async Task <ActionResult <AgentJourneyPlanView> > CreateAgentJourneyPlan(AgentJourneyPlanView agentJourneyPlanView)
        {
            List <int> customerIdList = new List <int>();
            int        agentId        = _context.Users.Where(obj => obj.FirstName + ' ' + obj.LastName == agentJourneyPlanView.saleAgentName).FirstOrDefault().Id;

            //    string status = "";
            for (int i = 0; i < agentJourneyPlanView.customerNameList.Count; i++)
            {
                AgentOrderStatus agentOrderStatus = new AgentOrderStatus();
                agentOrderStatus.AgentCustomerId     = getAgentCustomerId(agentJourneyPlanView.customerNameList[i], agentId);
                agentOrderStatus.StartDate           = System.DateTime.Parse(agentJourneyPlanView.startDate);
                agentOrderStatus.EndDate             = System.DateTime.Parse(agentJourneyPlanView.endDate);
                agentOrderStatus.AgentTargetStatusId = 1;
                agentOrderStatus.OrderStatusId       = 1;
                _context.AgentOrderStatus.Add(agentOrderStatus);
                await _context.SaveChangesAsync();
            }
            var data = (from user in _context.Users
                        join userrole in _context.UserRoles on user.Id equals userrole.UserId
                        join role in _context.Roles on
                        userrole.RoleId equals role.Id
                        where role.Name == "sale agent"
                        join distagent in _context.DistributorAgents on user.Id equals distagent.UserId
                        where distagent.DistributorId == agentJourneyPlanView.distId
                        join agentcus in _context.AgentCustomer on user.Id equals agentcus.SaleAgentId
                        join
                        agentordstat in _context.AgentOrderStatus on agentcus.Id equals agentordstat.AgentCustomerId
                        join tartype in _context.TargetStatusType on
                        agentordstat.AgentTargetStatusId equals tartype.Id
                        join ordertype in _context.OrderStatusType on agentordstat.OrderStatusId equals ordertype.Id
                        //join
                        //orderprod in _context.OrderProducts on agentordstat.Id equals orderprod.AgentOrderStatusId join invent in _context.Inventory on
                        // orderprod.InventoryId equals invent.Id join Prod in _context.Products on invent.ProductId equals Prod.Id
                        select new
            {
                agentObject = user,
                CustomerName = (from customer in _context.Users where customer.Id == agentcus.CustomerId select new { customerObject = customer }).FirstOrDefault(),
                TargetType = tartype.Type,
                OrderType = ordertype.OrderStatus
            }
                        ).ToList();

            //    status = "success";
            return(Ok(new { AgentJourneyPlanStatus = "SaveSuccess", distributorAgentCustomerDetailList = data }));

            //   return Ok(new { AgentJourneyPlanStatus = status });
        }
        public async Task <ActionResult <AgentJourneyPlanView> > updateJourneyPlan(AgentJourneyPlanView agentJourneyPlanView)
        {
            AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Where(obj => obj.Id == agentJourneyPlanView.agentOrderStatusId).FirstOrDefault();

            agentOrderStatus.OrderStatusId       = 2;
            agentOrderStatus.AgentTargetStatusId = 1;
            agentOrderStatus.StartDate           = System.DateTime.Parse(agentJourneyPlanView.startDate);
            agentOrderStatus.EndDate             = System.DateTime.Parse(agentJourneyPlanView.endDate);
            _context.AgentOrderStatus.Update(agentOrderStatus);
            _context.SaveChangesAsync();


            var data = (from user in _context.Users
                        join userrole in _context.UserRoles on user.Id equals userrole.UserId
                        join role in _context.Roles on
                        userrole.RoleId equals role.Id
                        where role.Name == "sale agent"
                        join distagent in _context.DistributorAgents on user.Id equals distagent.UserId
                        where distagent.DistributorId == agentJourneyPlanView.distId
                        join agentcus in _context.AgentCustomer on user.Id equals agentcus.SaleAgentId
                        join
                        agentordstat in _context.AgentOrderStatus on agentcus.Id equals agentordstat.AgentCustomerId
                        join tartype in _context.TargetStatusType on
                        agentordstat.AgentTargetStatusId equals tartype.Id
                        join ordertype in _context.OrderStatusType on agentordstat.OrderStatusId equals ordertype.Id
                        //join
                        //orderprod in _context.OrderProducts on agentordstat.Id equals orderprod.AgentOrderStatusId join invent in _context.Inventory on
                        // orderprod.InventoryId equals invent.Id join Prod in _context.Products on invent.ProductId equals Prod.Id
                        select new
            {
                agentObject = user,
                CustomerName = (from customer in _context.Users where customer.Id == agentcus.CustomerId select new { customerObject = customer }).FirstOrDefault(),
                TargetType = tartype.Type,
                OrderType = ordertype.OrderStatus
            }
                        ).ToList();

            //    status = "success";
            return(Ok(new { AgentJourneyPlanStatus = "UpdateSuccess", distributorAgentCustomerDetailList = data }));
        }
Esempio n. 6
0
        public async Task <ActionResult <CartProductView> > PostOrderProducts([FromBody]  PlaceOrderView orderProductsList)
        {
            string status = "";

            try
            {
                foreach (CartProductView orderProducts in orderProductsList.ListOrderProduct)
                {
                    Inventory previousInven = _context.Inventory.Find(orderProducts.InventoryId);
                    previousInven.Id = orderProducts.InventoryId;
                    previousInven.TotalPacket_Cartoon -= orderProducts.QTY;
                    _context.Inventory.Update(previousInven);
                    OrderProducts newOrderProduct = new OrderProducts();
                    newOrderProduct.AgentOrderStatusId = orderProducts.AgentOrderStatusId;
                    newOrderProduct.InventoryId        = orderProducts.InventoryId;
                    newOrderProduct.OrderDate          = System.DateTime.Parse(orderProducts.OrderDate);
                    newOrderProduct.QTY = orderProducts.QTY;
                    _context.OrderProducts.Add(newOrderProduct);
                    await _context.SaveChangesAsync();
                }
                AgentOrderStatus agentOrderStatus = _context.AgentOrderStatus.Find(orderProductsList.ListOrderProduct[0].AgentOrderStatusId);
                agentOrderStatus.AgentTargetStatusId = 3;   //productive target status(mean booking->(orderstatus:1)  success)
                _context.AgentOrderStatus.Update(agentOrderStatus);
                await _context.SaveChangesAsync();

                status = "BookingSuccess";
            }
            catch (Exception ex)
            {
                status = ex.Message;
            }

            // status = ;

            return(Ok(new { postCustomerOrder = status }));
            //  return CreatedAtAction("GetOrderProducts", new { id = orderProducts.Id }, orderProducts);
        }
        public async Task <ActionResult <AgentJourneyPlanView> > GetSpecificJourneyPlan(AgentOrderStatus agentOrderStat)
        {
            var data = (from agentOrderStatus in _context.AgentOrderStatus where agentOrderStatus.Id == agentOrderStat.Id join targettype in _context.TargetStatusType on
                        agentOrderStatus.AgentTargetStatusId equals targettype.Id join ordertype in _context.OrderStatusType on
                        agentOrderStatus.OrderStatusId equals ordertype.Id select new
                        { targettype = targettype.Type, ordertype = ordertype.OrderStatus, agentOrderStatusObject = agentOrderStatus });

            return(Ok(new { AgentViewJourneyPlanStatus = "GetSpecificSuccess", specificjourneyplan = data }));

            //   return Ok(new { AgentJourneyPlanStatus = status });
        }