Пример #1
0
        public GeneralResponse AddSuctionModeDetails(IEnumerable <AddSuctionModeDetailRequest> requests, Guid SuctionModeID, Guid CreateEployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (AddSuctionModeDetailRequest request in requests)
                {
                    SuctionModeDetail suctionModeDetail = new SuctionModeDetail();
                    suctionModeDetail.ID                    = Guid.NewGuid();
                    suctionModeDetail.CreateDate            = PersianDateTime.Now;
                    suctionModeDetail.CreateEmployee        = _employeeRepository.FindBy(CreateEployeeID);
                    suctionModeDetail.SuctionModeDetailName = request.SuctionModeDetailName;
                    suctionModeDetail.Discontinued          = request.Discontinued;
                    suctionModeDetail.SortOrder             = GetSortOrder();
                    suctionModeDetail.SuctionMode           = _suctionModeRepository.FindBy(SuctionModeID);
                    suctionModeDetail.RowVersion            = 1;
                    _suctionModeDetailRepository.Add(suctionModeDetail);
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Пример #2
0
        public GeneralResponse EditSuctionMode(EditSuctionModeRequestOld request)
        {
            GeneralResponse response    = new GeneralResponse();
            SuctionMode     suctionMode = new SuctionMode();

            suctionMode = _suctionModeRepository.FindBy(request.ID);

            if (suctionMode != null)
            {
                try
                {
                    suctionMode.ModifiedDate     = PersianDateTime.Now;
                    suctionMode.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID);
                    if (request.SuctionModeName != null)
                    {
                        suctionMode.SuctionModeName = request.SuctionModeName;
                    }

                    if (suctionMode.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("کارشناس محترم، یک کاربر همزمان با شما در حال ویرایش این رکورد است. بنابراین اطلاعات شما ذخیره نمی شود.");
                        return(response);
                    }
                    else
                    {
                        suctionMode.RowVersion += 1;
                    }

                    if (suctionMode.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in suctionMode.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _suctionModeRepository.Save(suctionMode);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("هیچ موردی جهت ویرایش وجود ندارد.");
            }
            return(response);
        }