コード例 #1
0
        public IActionResult TakeAction([FromBody] OrderDTO order)
        {
            var result = _OrderRepositry.GetById(order.id);

            if (!string.IsNullOrEmpty(order.result) && result != null)
            {
                OrderResult orderResult = new OrderResult();
                orderResult.orderid    = order.id;
                orderResult.result     = order.result;
                orderResult.useraction = order.useraction;
                orderResult.createdate = DateTime.Now;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _OrderResultRepositry.Insert(orderResult);
                _OrderResultRepositry.Save();
                _OrderRepositry.Update(result);
                _OrderRepositry.Save();
            }
            if (order.Done == true && result != null)
            {
                result.Done       = order.Done;
                result.useraction = order.useraction;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _OrderRepositry.Update(result);
                _OrderRepositry.Save();
            }
            if (order.late.HasValue && result != null)
            {
                if (order.late.Value < DateTime.Now || order.late.Value.Hour < 9 || order.late.Value.Hour > 17)
                {
                    return(Ok("Invalid Date"));
                }

                var difference = (int)(order.late.Value - result.create).TotalHours;
                result.count      = difference;
                result.useraction = order.useraction;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _OrderRepositry.Update(result);
                _OrderRepositry.Save();
            }
            return(Ok(true));
        }
コード例 #2
0
        public IActionResult TakeAction([FromBody] CheckDTO Check)
        {
            var result = _CheckRepositry.GetById(Check.id);

            if (!string.IsNullOrEmpty(Check.result) && result != null)
            {
                CheckResult CheckResult = new CheckResult();
                CheckResult.orderid    = Check.id;
                CheckResult.result     = Check.result;
                CheckResult.useraction = Check.useraction;
                CheckResult.createdate = DateTime.Now;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _CheckResultRepositry.Insert(CheckResult);
                _CheckResultRepositry.Save();
                _CheckRepositry.Update(result);
                _CheckRepositry.Save();
            }
            if (Check.Done == true && result != null)
            {
                result.Done       = Check.Done;
                result.useraction = Check.useraction;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _CheckRepositry.Update(result);
                _CheckRepositry.Save();
            }
            if (Check.late.HasValue && result != null)
            {
                if (Check.late.Value < DateTime.Now || Check.late.Value.Hour < 9 || Check.late.Value.Hour > 17)
                {
                    return(Ok("Invalid Date"));
                }
                var difference = (int)(Check.late.Value - result.create).TotalHours;
                result.count      = difference;
                result.useraction = Check.useraction;
                var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault();
                if (lockresult != null)
                {
                    _LockRepositry.Delete(lockresult.id);
                    _LockRepositry.Save();
                }
                _CheckRepositry.Update(result);
                _CheckRepositry.Save();
            }
            return(Ok(true));
        }
コード例 #3
0
        public JsonResult GetAll()
        {
            var cate = new CrudRepositry <CategoryMaster>();
            var dt   = repository.GetAll().Join(cate.GetAll(),
                                                product => product.CategoryID,
                                                category => category.CategoryID,
                                                (product, category) => new
            {
                ProductID      = product.ProductID,
                CategoryID     = product.CategoryID,
                CategoryName   = category.Name,
                Name           = product.Name,
                Description    = product.Description,
                Quantity       = product.Quantity,
                Price          = product.Price,
                Discount       = product.Discount,
                ExpirationDate = Convert.ToDateTime(product.ExpirationDate).ToString("mm/dd/yyyy")
            }).ToList();

            if (dt != null)
            {
                if (dt.Count() > 0)
                {
                    return(Json(new { draw = 0, recordsTotal = dt.Count(), recordsFiltered = dt.Count(), data = dt }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { draw = 0, recordsTotal = 0, recordsFiltered = 0, data = "" }, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public ActionResult Index()
        {
            ViewBag.userdetails = repository.GetAll().OrderBy(m => m.DisplayOrder);

            TempData["IsEdit"] = "0";

            return(View());
        }
コード例 #5
0
 public string AddFollowUp([FromBody] FollowUpDTO followUpDTO)
 {
     try
     {
         var customer = _CustomerRepo.GetById(followUpDTO.customerid);
         if (followUpDTO.delay.HasValue)
         {
             if (followUpDTO.delay.Value < DateTime.Now || followUpDTO.delay.Value.Hour < 9 || followUpDTO.delay.Value.Hour > 17)
             {
                 return("Invalid Date");
             }
             if (customer != null)
             {
                 var difference = (long)(followUpDTO.create - customer.created.AddDays(customer.count).AddHours(customer.hours == null?0:(double)customer.hours)).TotalHours;
                 customer.hours = difference;
                 _CustomerRepo.Update(customer);
                 _CustomerRepo.Save();
                 var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == followUpDTO.customerid && s.objectname == "FollowUp").FirstOrDefault();
                 if (lockresult != null)
                 {
                     _LockRepositry.Delete(lockresult.id);
                     _LockRepositry.Save();
                 }
             }
         }
         else
         {
             FollowUp followUp = new FollowUp();
             followUp.create      = followUpDTO.create;
             followUp.customerid  = followUpDTO.customerid;
             followUp.discribtion = followUpDTO.discribtion;
             followUp.order       = followUpDTO.order;
             followUp.followup    = followUpDTO.followup;
             followUp.ownerid     = followUpDTO.ownerid;
             if (customer != null)
             {
                 customer.hours = null;
                 customer.count = Time[customer.count];
                 _CustomerRepo.Update(customer);
                 _CustomerRepo.Save();
                 _genericRepositry.Insert(followUp);
                 _genericRepositry.Save();
             }
             if (followUp.order)
             {
                 Order order = new Order();
                 order.count       = 0;
                 order.customerid  = customer.id;
                 order.ownerid     = followUp.ownerid;
                 order.description = followUp.discribtion;
                 order.create      = DateTime.Now;
                 order.Done        = false;
                 order.id          = 0;
                 _OrderRepositry.Insert(order);
                 _OrderRepositry.Save();
             }
             if (followUp.followup)
             {
                 Check Check = new Check();
                 Check.count       = 0;
                 Check.customerid  = customer.id;
                 Check.ownerid     = followUp.ownerid;
                 Check.description = followUp.discribtion;
                 Check.create      = DateTime.Now;
                 Check.Done        = false;
                 Check.id          = 0;
                 _CheckRepositry.Insert(Check);
                 _CheckRepositry.Save();
             }
             var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == followUpDTO.customerid && s.objectname == "FollowUp").FirstOrDefault();
             if (lockresult != null)
             {
                 _LockRepositry.Delete(lockresult.id);
                 _LockRepositry.Save();
             }
         }
         return("Added Done");
     }
     catch (Exception e)
     {
         return("Error in Add");
     }
 }
コード例 #6
0
        public IActionResult GetAll()
        {
            var result = _CustomerRepo.GetAll().ToList();

            return(Ok(result));
        }
コード例 #7
0
        public IActionResult NewOrders()
        {
            var result = _CheckRepositry.GetAll().Where(s => _CheckResultRepositry.GetAll().Where(x => x.orderid == s.id).Count() == 0 && s.create.AddHours(s.count) <= DateTime.Now && s.Done == false).Select(s => s.customerid).ToList().Distinct();

            return(Ok(result));
        }
コード例 #8
0
        public IActionResult GetRoles()
        {
            var roles = _RolesRepo.GetAll();

            return(Ok(roles));
        }
コード例 #9
0
        public IActionResult GetAll(int CustomerId)
        {
            var result = _EmpRepo.GetAll().Where(s => s.customerid == CustomerId).ToList();

            return(Ok(result));
        }