예제 #1
0
        public GeneralResponse AddCondition(AddConditionRequestOld request)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                Condition condition = new Condition();
                condition.ID             = Guid.NewGuid();
                condition.CreateDate     = PersianDateTime.Now;
                condition.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID);
                condition.ConditionTitle = request.ConditionTitle;
                //condition.CriteriaOperator = request.CriteriaOperator;
                condition.ErrorText  = request.ErrorText;
                condition.nHibernate = request.nHibernate;
                //condition.PropertyName = request.PropertyName;
                condition.QueryText = request.QueryText;
                //condition.Value = request.Value;
                condition.RowVersion = 1;

                #region Validation
                if (condition.GetBrokenRules().Count() > 0)
                {
                    foreach (BusinessRule businessRule in condition.GetBrokenRules())
                    {
                        response.ErrorMessages.Add(businessRule.Rule);
                    }

                    return(response);
                }
                #endregion

                _conditionRepository.Add(condition);
                _uow.Commit();

                ////response.success = true;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);

                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add("FIRST INNER EXPCEPTION: " + ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        response.ErrorMessages.Add("SECOND INNER EXPCEPTION: " + ex.InnerException.InnerException.Message);
                    }
                }
            }

            return(response);
        }
예제 #2
0
        public IActionResult Post(Condition condition)
        {
            var currentUserProfile = GetCurrentUserProfile();

            condition.UserProfileId  = currentUserProfile.Id;
            condition.CreateDateTime = DateTime.Now;
            _conditionRepository.Add(condition);
            return(Ok(CreatedAtAction("Get", new { id = condition.Id }, condition)));
        }