public async Task <IActionResult> Create(StatusDTO statusDto) { var status = _mapper.Map <Status>(statusDto); await _service.Create(status); return(Ok()); }
public IHttpActionResult CreateStatus(StatusApiModel model) { var time = DateTime.Now; var user = User.Identity.Name; var modelDto = new List <StatusDto>(); for (int i = 0; i < model.ProductIds.Count; i++) { var statusDto = new StatusDto { InventoryId = model.InventoryId, ProductId = model.ProductIds[i], ExpQuantity = model.ExpQuantities[i], CurQuantity = model.CurQuantities[i], Difference = model.Differences[i], IsStarted = model.IsStarted, ByUser = user, Updated = time }; modelDto.Add(statusDto); } _statusService.Create(modelDto); return(Ok()); }
public int Create(StatusDTO status) { int returnValue; using (UnitOfWorkProvider.Create()) { returnValue = statusService.Create(status); } return(returnValue); }
// POST: api/Status public IHttpActionResult Post(Status status) { IHttpActionResult returnResult = null; AddServiceValidationToModelState(statusService.Validate(status)); if (ModelState.IsValid) { statusService.Create(status); returnResult = CreatedAtRoute("DefaultApi", new { id = status.ID }, status); } else { returnResult = BadRequest(ModelState); } return(returnResult); }
public IActionResult Create([FromForm] StatusModel model) //[FromForm] - potrzebne do mapowania danych z formularza na obiekt w przypadku gdy korzystamy z Razora lub zwykłego HTMLa. Przy taghelperach nie jest to konieczne tak jak w tym przypadku { if (ModelState.IsValid) { try { //model.UserId = User.Identity.Name; _modelService.Create(model); //context.SaveChanges(); } catch (Exception) { return(View(model)); } return(Redirect("Index")); } else { return(View(model)); } }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentStatus.Name)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_polje_naziv")); return; } if (String.IsNullOrEmpty(CurrentStatus.ShortName)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_polje_skraćeni_naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentStatus.IsSynced = false; CurrentStatus.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentStatus.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; StatusResponse response = new StatusSQLiteRepository().Delete(CurrentStatus.Identifier); response = new StatusSQLiteRepository().Create(CurrentStatus); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; return; } response = StatusService.Create(CurrentStatus); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")) + response.Message; SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; StatusCreatedUpdated(); if (IsCreateProcess) { CurrentStatus = new StatusViewModel(); CurrentStatus.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtName.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); }