示例#1
0
        public bool AddComment(ContractComment contractComment)
        {
            var validStatuses = new[]
            {
                DataModel.Contract.StatusOnCorrection, DataModel.Contract.StatusInWork,
                DataModel.Contract.StatusCorrected
            };
            var contract =
                AppContext.Contracts.Include(c => c.ContractStatus)
                .FirstOrDefault(e => e.Id == contractComment.ContractId);

            if (!validStatuses.Contains(contract.ContractStatus.Code))
            {
                return(false);
            }
            //var contractStatus = DictionaryHelper.GetDicItemByCode(Dictionary.ContractStatus.DicCode,
            //    DataModel.Contract.StatusOnCorrection);
            if (contractComment.Id == Guid.Empty)
            {
                AppContext.ContractComments.Add(contractComment);
            }
            else
            {
                AppContext.Entry(contractComment).State = EntityState.Modified;
            }
            AppContext.SaveChanges();
            //var contractOwner = AppContext.Employees.FirstOrDefault(e => e.Id == contract.OwnerId);
            //NotificationManager nm = new NotificationManager();
            //nm.SendNotification("К договору добавлены замечания", ObjectType.Contract, contract.Id, contract.OwnerId,
            //    contractOwner.Email);
            return(true);
        }
示例#2
0
        public ActionResult AddComment(ContractComment contractComment)
        {
            var result = _contractRepository.AddComment(contractComment);

            return(Json(!result ? (object)"unavaliableAction" : result, JsonRequestBehavior.AllowGet));
        }