Exemplo n.º 1
0
        public ActionResult Confirm(ConfirmDM confirmDM)
        {
            if (!confirmDM.IsConfirmed && String.IsNullOrEmpty(confirmDM.Description))
            {
                ModelState.AddModelError("", "Не указана причина отклонения");
            }

            if (ModelState.IsValid)
            {
                ConfirmDTO confirm = _rentMapperDM.ToConfirmDTO.Map <ConfirmDM, ConfirmDTO>(confirmDM);
                confirm.User = new User()
                {
                    Id = User.Identity.GetUserId()
                };
                _managerService.ConfirmOrder(confirm);
                _logWriter.CreateLog("Подтвердил заказ" + confirm.Order.Id, User.Identity.GetUserId());

                return(RedirectToAction("ShowConfirms", "Manager", null));
            }

            var orderDTO = _managerService.GetOrder(confirmDM.Order.Id, true);

            confirmDM.Order         = _rentMapperDM.ToOrderDM.Map <OrderDTO, OrderDM>(orderDTO);
            confirmDM.Order.Profile = _identityMapperDM.ToProfileDM.Map <ProfileDTO, ProfileDM>(orderDTO.Profile);

            return(View(confirmDM));
        }
Exemplo n.º 2
0
 public HttpResponseMessage PostConfirmPaper(ConfirmDTO dto)
 {
     dto.Username = HttpContext.Current.Session["username"].ToString();
     repository.ConfirmSystemPushAuthor(dto);
     return(new HttpResponseMessage()
     {
         Content = new StringContent("success")
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// 用户确认系统推荐的论文信息。如果系统只找到一个候选人,用户可以接受或者拒绝
        /// 如果系统找到多个候选人,用户只能拒绝
        /// </summary>
        /// <param name="dto">有三个属性:
        /// 1.Username,用户名。
        /// 2.CandidateId,候选人信息的ID。
        /// 3.Belong, 用户接受为true,用户拒绝为false
        /// </param>
        public void ConfirmSystemPushAuthor(ConfirmDTO dto)
        {
            var candidate = context.Candidate.FirstOrDefault(c => c.Id == dto.CandidateId);

            if (null == candidate)
            {
                return;
            }
            //只能确认推荐给他的论文
            if (!dto.Username.Equals(candidate.PersonNo))
            {
                return;
            }
            //该条候选人信息必须是由系统分发的
            if (candidate.Operator.Equals("system"))
            {
                return;
            }
            //该条候选人信息的状态必须是待审核
            if (candidate.status != (int)CandidateStatus.CHECK)
            {
                return;
            }

            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    if (dto.Belongs)
                    {
                        //如果只有一条系统推荐信息
                        if (candidate.Author.Candidate.Count == 1)
                        {
                            candidate.status = (int)CandidateStatus.RIGHT;
                            context.SaveChanges();
                            UpdatePaperStatus(candidate.Author.Paper);
                        }
                    }
                    else
                    {
                        candidate.status = (int)CandidateStatus.WRONG;
                    }
                    context.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Confirm order.
 /// </summary>
 /// <param name="confirmDTO">Confirm object</param>
 public void ConfirmOrder(ConfirmDTO confirmDTO)
 {
     try
     {
         if (RentUnitOfWork.Orders.Get(confirmDTO.Order.Id).Confirm == null ||
             RentUnitOfWork.Orders.Get(confirmDTO.Order.Id).Confirm.Count == 0)
         {
             var confirm = RentMapperDTO.ToConfirm.Map <ConfirmDTO, Confirm>(confirmDTO);
             confirm.ManagerId = confirmDTO.User.Id;
             confirm.Order     = RentUnitOfWork.Orders.Get(confirmDTO.Order.Id);
             RentUnitOfWork.Confirms.Create(confirm);
             RentUnitOfWork.Save();
         }
     }
     catch (Exception e)
     {
         CreateLog(e, "ManagerService", "ConfirmOrder");
     }
 }