public GeneralResponse EditNetwork(EditNetworkRequestOld request) { GeneralResponse response = new GeneralResponse(); Network network = new Network(); network = _networkRepository.FindBy(request.ID); if (network != null) { try { network.ModifiedDate = PersianDateTime.Now; network.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID); network.DeliverWhenCreditLow = request.DeliverWhenCreditLow; if (request.NetworkName != null) { network.NetworkName = request.NetworkName; } if (request.Note != null) { network.Note = request.Note; } if (network.RowVersion != request.RowVersion) { response.ErrorMessages.Add("کارشناس محترم، یک کاربر همزمان با شما در حال ویرایش این رکورد است. بنابراین اطلاعات شما ذخیره نمی شود."); return(response); } else { network.RowVersion += 1; } if (network.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in network.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } _networkRepository.Save(network); _uow.Commit(); ////response.success = true; } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } } else { response.ErrorMessages.Add("هیچ موردی جهت ویرایش وجود ندارد."); } return(response); }
public GeneralResponse AddNetworkCenter(AddNetworkCenterRequest request) { GeneralResponse response = new GeneralResponse(); try { NetworkCenter networkCenter = new NetworkCenter(); networkCenter.Network = _networkRepository.FindBy(request.NetworkID); networkCenter.Center = _centerRepository.FindBy(request.CenterID); networkCenter.CreateDate = PersianDateTime.Now; networkCenter.CreateEmployee = _employeeRepository.FindBy(request.CreateEmployeeID); networkCenter.Status = (NetworkCenterStatus)request.Status; networkCenter.CanSale = request.CanSale; networkCenter.RowVersion = 1; _networkCenterRepository.Add(networkCenter); _uow.Commit(); ////response.success = true; // Validation if (networkCenter.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in networkCenter.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); } return(response); }