public void UpdateDetail(DetailDTO detailDTO) { Mapper.Initialize(cfg => cfg.CreateMap <DetailDTO, Detail>()); Detail newdetail = Mapper.Map <DetailDTO, Detail>(detailDTO); if (detailDTO.DetailId == 0) { Database.Details.Create(newdetail); } else { Detail detail = Database.Details.Get(newdetail.DetailId); if (detail != null) { detail.DetailId = newdetail.DetailId; detail.NomenclativeCode = newdetail.NomenclativeCode; detail.DetailName = newdetail.DetailName; detail.SpecialConside = newdetail.SpecialConside; detail.DetailCount = newdetail.DetailCount; detail.DateAdded = newdetail.DateAdded; detail.StockmanId = newdetail.StockmanId; detail.Stockman = newdetail.Stockman; Database.Details.Update(detail); } } }
public async Task <bool> AddAsync(DetailDTO detailDTO) { var detail = _mapper.Map <DetailDTO, Detail>(detailDTO); var result = await _detailRepository.Add(detail); return(result); }
public ActionResult <Detail> PostDetail(DetailDTO detailDTO) { Detail detailToCreate = new Detail(detailDTO.LangeBeschrijving, detailDTO.BewoonbareOppervlakte, detailDTO.TotaleOppervlakte, detailDTO.EPCWaarde, detailDTO.KadastraalInkomen); _detailRepository.Add(detailToCreate); _detailRepository.SaveChanges(); return(CreatedAtAction(nameof(GetDetail), new { id = detailToCreate.DetailID }, detailToCreate)); }
//[HttpGet] public ActionResult DeleteDetail(int id) { DetailDTO deletedDTO = detailService.GetDetailById(id); if (deletedDTO != null) { return(PartialView("DeleteDetail", deletedDTO)); } return(View("Index")); }
public async Task <ActionResult <DetailDTO> > Put(DetailDTO detailDTO) { if (detailDTO == null) { return(BadRequest()); } await _detailService.UpDateAsync(detailDTO); return(Ok(detailDTO)); }
public async Task <IActionResult> Post([FromBody] DetailDTO value) { try { return(Ok(await _iEFDetail.AddDetails(value))); } catch { return(StatusCode(404)); } }
public async Task <IActionResult> Put([FromBody] DetailDTO value) { try { await _iEFDetail.UpdateDetails(value); return(StatusCode(204)); } catch { return(StatusCode(404)); } }
public ActionResult Edit(int id) { DetailDTO det = detailService.GetDetailById(id); Mapper.Initialize(cfg => cfg.CreateMap <DetailDTO, DetailViewModel>()); var detailview = Mapper.Map <DetailDTO, DetailViewModel>(det); if (detailview != null) { GetSelectListStockmen(); return(PartialView(detailview)); } return(View("Index")); }
public ActionResult DeleteConfirmed(int id) { DetailDTO deletedDTO = detailService.GetDetailById(id); if (deletedDTO == null) { return(HttpNotFound()); } if (deletedDTO != null) { DetailDTO deleted = detailService.DeleteDetail(id); } return(RedirectToAction("Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DetailDTO = await _context.DetailDTO.FirstOrDefaultAsync(m => m.Id == id); if (DetailDTO == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DetailDTO = await _context.DetailDTO.FindAsync(id); if (DetailDTO != null) { _context.DetailDTO.Remove(DetailDTO); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void InsertDetail(DetailDTO detailDTO) { Stockman stockman = Database.Stockmen.Get(detailDTO.StockmanId); // валидация if (stockman == null) { throw new ValidationException("Кладовщик не найден", ""); } if (detailDTO.NomenclativeCode != null) { String input = @"^[a-zA-Z]{3}-\d{6}$"; if (Regex.IsMatch(detailDTO.NomenclativeCode, input)) { Detail detail = new Detail { DetailId = detailDTO.DetailId, NomenclativeCode = detailDTO.NomenclativeCode, DetailName = detailDTO.DetailName, SpecialConside = detailDTO.SpecialConside, DetailCount = detailDTO.DetailCount, DateAdded = detailDTO.DateAdded, StockmanId = stockman.StockmanId, Stockman = stockman }; Database.Details.Create(detail); Database.Save(); } else { throw new ValidationException("Номенклатурный код не соответствует шаблону", ""); } } else { throw new ValidationException("Заполните номенклатурный код", ""); } }
public async Task <string> AddDetails(DetailDTO detail) { DetailValidator validator = new DetailValidator(); ValidationResult results = validator.Validate(detail); var x = _mapper.Map <DetailDTO, Detail>(detail); if (!results.IsValid) { foreach (var failure in results.Errors) { string error = ("Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage); return(error); } return("Error"); } else { await _eFUnitOfWork.EFDetailRepository.Add(x); return("Деталь успішно добавлено!"); } }
public static Detail FromDTO(DetailDTO dto) { var detail = Mapper.Map <Detail>(dto); return(detail); }
public async Task <ActionResult <DetailDTO> > Post([FromBody] DetailDTO detailDTO) { await _detailService.UpDateAsync(detailDTO); return(Ok(detailDTO)); }
public static Detail Map(DetailDTO dto) => new Detail(dto);
public DetailDTO insertSaleNote(Note note, List <Detail> details) { using (var sqlConnection = new SqlConnection(conexion)) { sqlConnection.Open(); DetailDTO detailDTO = new DetailDTO(); using (var transaction = sqlConnection.BeginTransaction()) { try { note.typeNote = 2; string sqlInsertNote = "insert into tblNotes (nroNote,dateNote,description,total,typeNote,idCompany,idUser,idVoucher) values (@nroNote,@dateNote," + "@description,@total,@typeNote,@idCompany,@idUser,@idVoucher)SELECT SCOPE_IDENTITY()"; var idRes = sqlConnection.ExecuteScalar(sqlInsertNote, note, transaction: transaction); int idNote = Convert.ToInt32(idRes); string getNote = "select * from tblNotes where idNote = " + idNote; Note noteGet = sqlConnection.Query <Note>(getNote, commandType: System.Data.CommandType.Text, transaction: transaction).FirstOrDefault(); detailDTO.note = noteGet; if (details.Count > 0) { var dateEntry = DateTime.Now; foreach (var detail in details) { detail.dateEntry = dateEntry; detail.idNote = idNote; detail.idVoucher = 1; string sqlInsertLote = "insert into tblDetail (idArticle,nroLote,idNote,quantityDetail,priceSale,idVoucher)" + " values (@IdArticle,@nroLote,@idNote,@quantityDetail,@priceSale,@idVoucher)"; sqlConnection.Execute(sqlInsertLote, detail, transaction: transaction); ////Edit Article string updateArticle = "update tblArticles set quantity = quantity -" + detail.quantityDetail + " where idArticle = " + detail.idArticle; sqlConnection.Execute(updateArticle, transaction: transaction); } detailDTO.details = details; } //Obtengo la configuracion de las cuentas para generar el comprobante string getConfiguration = "select * from tblConIntegration where idCompany = " + note.idCompany + " and isIntegration = 1"; ConfigurationIntegration configurationIntegration = sqlConnection.Query <ConfigurationIntegration>(getConfiguration, transaction: transaction).FirstOrDefault(); //Obtengo la moneda actual string getCurrencyMain = "select * from tblCompanyCurrency where idCompany = " + note.idCompany + " and active = 1 "; var currency = sqlConnection.Query <CompanyCurrency>(getCurrencyMain, commandType: System.Data.CommandType.Text, transaction: transaction).FirstOrDefault(); if (configurationIntegration == null) { transaction.Commit(); detailDTO.response = new Response { Done = true, Message = "Creado exitosamente", Value = 0 }; return(detailDTO); } Voucher voucher = new Voucher(); voucher.dateVoucher = note.dateNote; voucher.gloss = "Venta de Mercaderias"; voucher.typeVoucher = 1; voucher.tc = currency.exchange; voucher.idUser = 1; voucher.idCompany = note.idCompany; voucher.idCurrency = currency.idCurrencyMain; voucher.serieVoucher = getIdNext(note.idCompany); List <VoucherDetail> listVoucher = new List <VoucherDetail>(); VoucherDTO voucherDTO = _voucher.sendAll(voucher, makeListVoucherSale(configurationIntegration, note.total, voucher.idVoucher)); if (voucherDTO.response.Done == true) { transaction.Commit(); detailDTO.details = details; detailDTO.response = new Response { Done = true, Message = "Creado exitosamente", Value = 0 }; return(detailDTO); } else { transaction.Rollback(); detailDTO.response = new Response { Done = false, Message = voucherDTO.response.Message, Value = 0 }; return(detailDTO); } }catch (Exception e) { transaction.Rollback(); detailDTO.response = new Response { Done = false, Message = "Error", Value = 0 }; return(detailDTO); } } } }
public async Task UpdateDetails(DetailDTO detail) { var x = _mapper.Map <DetailDTO, Detail>(detail); await _eFUnitOfWork.EFDetailRepository.Update(x); }