public void Add_Gets_Added() { var newSupplier = new Supplier { Name = "newSupplier" + DateTime.Now.Ticks }; _supplierRepository.Add(newSupplier); var suppliers = _supplierRepository.GetAll(); Assert.True(suppliers.Any(o => o.Name == newSupplier.Name)); }
public int CreateSupplier(string name) { if (name == null) { return(0); } var isExisting = _supplierRepository.FindBy(x => x.Name == name).FirstOrDefault() != null; if (!isExisting) { var newInstance = new Supplier() { Id = Guid.NewGuid(), Name = name, Type = SupplierType.公寓 }; _supplierRepository.Add(newInstance); _supplierRepository.Save(); return(1); } else { return(0); } }
public bool AddSupplier(SupplierVM _SupplierVM) { try { tblSupplier supplier = new tblSupplier(); supplier.Address = _SupplierVM.Address; supplier.CST = _SupplierVM.CST; supplier.District = _SupplierVM.District; supplier.Email = _SupplierVM.Email; supplier.IsActive = _SupplierVM.IsActive; supplier.MobileNo1 = _SupplierVM.MobileNo1; supplier.MobileNo2 = _SupplierVM.MobileNo2; supplier.Owner = _SupplierVM.Owner; supplier.PinCode = _SupplierVM.PinCode; supplier.State = _SupplierVM.State; supplier.SupplierCode = _SupplierVM.SupplierCode; supplier.SupplierName = _SupplierVM.SupplierName; supplier.TelePhone1 = _SupplierVM.TelePhone1; supplier.TelePhone2 = _SupplierVM.TelePhone2; supplier.VAT = _SupplierVM.VAT; supplier.IsDeleted = false; _SupplierRepository.Add(supplier); _unitOfWork.Complete(); return(true); } catch (Exception e) { throw e; } }
//Thêm Brand mới vào bảng Line public async Task <bool> Add(SuppilerDto model) { var Line = _mapper.Map <Supplier>(model); _repoLine.Add(Line); return(await _repoLine.SaveAll()); }
public async Task <bool> Add(Supplier supplier) { if (!PerformValidation(new SupplierValidation(), supplier) || !PerformValidation(new AddressValidation(), supplier.Address)) { return(false); } if (_supplierRepository.Search(s => s.Document == supplier.Document).Result.Any()) { Notify("There is already a supplier with this document entered."); return(false); } var address = await _addressRepository.GetAddressBySupplier(id); if (address != null) { await _addressRepository.Remove(address.Id); } await _supplierRepository.Add(supplier); return(true); }
//Thêm Supplier mới vào bảng Supplier public async Task <bool> Add(SuppilerDto model) { var Supplier = _mapper.Map <Supplier>(model); Supplier.isShow = true; _repoSupplier.Add(Supplier); return(await _repoSupplier.SaveAll()); }
public async Task <Supplier> CreateSupplier() { var supplier = new Supplier(Guid.NewGuid(), "New Orleans Cajun Delights", "Shelley Burke", "Order Administrator", "P.O. Box 78934", "New Orleans", "USA", "(100) 555-4822"); await _supplierRepository.Add(supplier); await _supplierRepository.UnitOfWork.Commit(); return(supplier); }
public async Task CreateSupplier(Supplier supplier, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); if (!IsValid(supplier)) { throw new BadHttpRequestException("Forncedor inválido"); } await _productRepository.Add(supplier, cancellationToken); }
public void Add(SupplierDto supplier_in) { Supplier supplier = new Supplier(supplier_in.ID, supplier_in.Name, supplier_in.Address, supplier_in.Email, supplier_in.Phone); foreach (GroupDto groupDto in supplier_in.Groups) { supplier.Groups.Add(GroupRepository.GetById(groupDto.ID)); } SupplierRepository.Add(supplier); }
public void InsertSupplier(SupplierViewModel supplier, int userId) { Supplier entity = new Supplier(); Map(supplier, entity); _supplierRepository.AttachNavigation(entity.City); entity.CreateUserId = entity.ModifyUserId = userId; entity.CreateDate = entity.ModifyDate = DateTime.Now; entity.Status = (int)DbConstant.DefaultDataStatus.Active; _supplierRepository.Add(entity); _unitOfWork.SaveChanges(); }
private async Task <Supplier> GetSupplierByName(string name, string userId) { var supplier = await _supplierRepository.GetByName(name, userId); if (supplier == null) { supplier = _supplierFactory.Create(name, userId); await _supplierRepository.Add(supplier); } return(supplier); }
private SupplierModel Create(SupplierModel item) { var data = item.ConvertToData(); using (_unitOfWorkFactory.Create()) { _supplierRepository.Add(data); } return(data.ConvertToModel()); }
public bool AddSupplier(Supplier supplier) { _supplierRepository.Add(supplier); try { SaveSupplier(); return(true); } catch (Exception e) { return(false); } }
public IActionResult CreateSupplier(Supplier supplier) { try { if (ModelState.IsValid) { if (supplier.IdSupplier == 0) { _iSupplierRepository.Add(supplier); _iSupplierRepository.Save(RequestContext); HttpContext.Session.Remove("ICN"); } else { var data = _iSupplierRepository.All.AsNoTracking().ToList().FirstOrDefault(p => p.IdSupplier == supplier.IdSupplier); PropertyCopy.Copy(supplier, data); _iSupplierRepository.Update(supplier); _iSupplierRepository.Save(RequestContext); } var suppliers = _iSupplierRepository.All.ToList(); List <Supplier> cls = new List <Supplier>(); foreach (var c in suppliers) { cls.Add(c); } return(Json(new { isValid = true, html = Helper .RenderRazorViewToString(this, "_ViewListSuppliers", cls) })); } return(Json(new { isValid = false, html = Helper .RenderRazorViewToString(this, "CreateSupplier", supplier) })); } catch (Exception ex) { Console.WriteLine(ex); return(Json(new { isValid = false, html = Helper .RenderRazorViewToString(this, "_ViewListSuppliers", _iSupplierRepository.All.ToList()) })); } }
public bool Add(SupplierViewModel entity) { if (entity == null) { return(false); } var supplier = new Supplier() { SupplierName = entity.SupplierName, Description = entity.Description }; return(_supplierRepository.Add(supplier)); }
public async Task Add(Supplier supplier) { if (!Validate(new SupplierValidation(), supplier) || !Validate(new AddressValidation(), supplier.Address)) { return; } if (_repository.Search(s => s.Document == supplier.Document).Result.Any()) { Notify("Já existe um fornecedor com este documento informado"); return; } await _repository.Add(supplier); }
public int Add(SupplierRequestDto request) { if (request == null) { throw new LogicalErrorException(ErrorCodes.INVALID_REQUEST, "Invalid request parameters."); } var result = JsonConvert.DeserializeObject <Supplier>(JsonConvert.SerializeObject(request)); // result.CreatedAt = DateTime.UtcNow; // result.UpdatedAt = DateTime.UtcNow; return(_dal.Add(result).Id); //TODO }
public Task <Unit> Handle(AddSupplierCommand request, CancellationToken cancellationToken) { var supplier = _mapper.Map <Entities.Supplier>(request); _supplierRepository.Add(supplier); _supplierRepository.SaveChanges(); foreach (var mask in request.Masks) { var result = _mapper.Map <Mask>(mask); result.SupplierId = supplier.Id; _maskRepository.Add(result); } _maskRepository.SaveChanges(); return(Task.FromResult(Unit.Value)); }
public override void Execute() { TypedResult = new AddSupplierResult(); CheckIfSupplierExist(); var supplier = supplierFactory.Create(); supplier.Name = SupplierName; suppliersRepository.Add(supplier); TypedResult.Supplier = supplier; base.Execute(); }
public IActionResult Create(Supplier model) { if (ModelState.IsValid) { Supplier newSup = new Supplier { SupName = model.SupName, Phone = model.Phone, Email = model.Email, OrgName = model.OrgName, Address = model.Address }; _supplierRepository.Add(newSup); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> CreateSupplierRelation([FromBody] ManageSupplierResource supplierResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var companySupplier = _mapper.Map <CompanySupplier>(supplierResource); await _supplierRepository.Add(companySupplier); await _unitOfWork.CompleteAsync(); var supplier = await _companyRepository.GetById(companySupplier.SupplierId); return(Ok(supplier)); }
public async Task <IActionResult> Create([FromBody] SupplieDto supplie) { if (supplie == null) { return(BadRequest("No existe un insumo para crear.")); } var newSupplie = mapper.Map <Supplie>(supplie); newSupplie.Id = Guid.NewGuid(); newSupplie.FechaCreacion = DateTime.Now; newSupplie.FechaModificacion = DateTime.Now; await supplieRepository.Add(newSupplie); return(Created(Url.Link("GetSupplie", new { id = newSupplie.Id }), newSupplie)); }
public async Task <IActionResult> CreateSupplier([FromBody] SaveSupplierResource model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var supplier = new Supplier(model.Name, model.Gstin, model.Address, model.State, model.ContactNumber, AccountingUnitId, model.RegistrationType, model.Email, AdminId); _supplierRepository.Add(supplier); await _unitOfWork.CompleteAsync(); return(Ok(_mapper.Map <Supplier, SupplierResource>(supplier))); }
public async Task <bool> Insert(Supplier supplier) { if (!RunValidation(new SupplierValidation(), supplier) || !RunValidation(new AddressValidation(), supplier.Address)) { return(false); } if (_supplierRepository.Find(f => f.Document == supplier.Document).Result.Any()) { Notify("Já existe um fornecedor com este documento informado."); return(false); } await _supplierRepository.Add(supplier); return(true); }
public async Task <IActionResult> Post(CreatingSupplierModel model) { if (ModelState.IsValid) { var s = new Supplier { Name = model.Name, PhoneNumber = model.PhoneNumber, Email = model.Email }; await repository.Add(s); var url = Url.Action("Get", new { id = s.Id }); return(Created(url, s)); } return(BadRequest(ErrorResponse.FromModelState(ModelState))); }
public CreateSupplierResponse CreateSupplier(CreateSupplierRequest request) { CreateSupplierResponse response = new CreateSupplierResponse(); Supplier supplier = new Supplier(); supplier.CompanyName = request.CompanyName; supplier.ContactName = request.ContactName; supplier.ContactTitle = request.ContactTitle; supplier.Address = request.Address; supplier.City = request.City; supplier.Region = request.Region; supplier.PostalCode = request.PostalCode; supplier.Country = request.Country; supplier.Phone = request.Phone; supplier.Fax = request.Fax; supplier.HomePage = request.HomePage; supplier.Products = request.Products.ConvertToProducts(); if (supplier.GetBrokenRules().Count() > 0) { response.Errors = supplier.GetBrokenRules().ToList(); } else { try { _supplierRepository.Add(supplier); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { List <BusinessRule> errors = new List <BusinessRule>(); do { errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); ex = ex.InnerException; } while (ex != null); response.Errors = errors; } } return(response); }
public async Task <CommandResponse> Handle(SupplierAddCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(request.CommandResponse); } var supplier = new Supplier(Guid.NewGuid(), request.CompanyName, request.ContactName, request.ContactTitle, request.Adress, request.City, request.Country, request.Phone); supplier.Apply(new SupplierAddEvent(supplier.Id, supplier.CompanyName, supplier.ContactName, supplier.ContactTitle, supplier.Adress, supplier.City, supplier.Country, supplier.Phone)); await _supplierRepository.Add(supplier); await _eventSourceRepository.SaveAsync <Supplier>(supplier); return(await Commit(_supplierRepository.UnitOfWork, supplier.Id)); }
public void CreateSupplier(SupplierViewModel supplier) { var supplierInsert = Mapper.Map <SupplierViewModel, Supplier_M>(supplier); _supplierRepository.Add(supplierInsert); if (supplier.SettlementList != null && supplier.SettlementList.Count > 0) { _supplierSettlementRepository.Delete(set => set.SupplierMainC == supplier.InvoiceMainC && set.SupplierSubC == supplier.InvoiceSubC); SaveSupplier(); for (var iloop = 0; iloop < supplier.SettlementList.Count; iloop++) { var settlement = Mapper.Map <SupplierSettlementViewModel, SupplierSettlement_M>(supplier.SettlementList[iloop]); _supplierSettlementRepository.Add(settlement); } } SaveSupplier(); }
public async Task <SupplierModel> AddOrUpdate(SupplierModel supplierModel) { var supplierInDb = await repository.GetAsync(supplierModel.Id); Supplier @new; if (supplierInDb == null) { var supplier = mapper.Map <Supplier>(supplierModel); @new = repository.Add(supplier); } else { @new = mapper.Map <SupplierModel, Supplier>(supplierModel, supplierInDb); repository.Update(supplierInDb); } repository.UnitOfWork.SaveChangesAsync(); return(mapper.Map <SupplierModel>(@new)); }
// [PrincipalPermission(SecurityAction.Demand, Role = Security.BomAdminRole)] public Supplier UpdateSupplier(Supplier supplier) { return(ExecuteFaultHandledOperation(() => { ISupplierRepository supplierRepository = _dataRepositoryFactory.GetDataRepository <ISupplierRepository>(); Supplier updatedEntity = null; if (supplier.Id == 0) { updatedEntity = supplierRepository.Add(supplier); } else { updatedEntity = supplierRepository.Update(supplier); } return updatedEntity; })); }