public async Task <IActionResult> AddOrganization(OrganizationForCreationDto organizationForCreationDto) { var organizationToCreate = _mapper.Map <Organization> (organizationForCreationDto); _repo.Add(organizationToCreate); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Could not add Organzation")); }
public async Task <IActionResult> AddVoter(VoterForCreationDto voterForCreationDto) { var voterToCreate = _mapper.Map <Voter> (voterForCreationDto); _repo.Add(voterToCreate); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Could not add voter")); }
private void btnDetailsSave_ItemClick(object sender, ItemClickEventArgs e) { if (!isNew) { _managerStockedDetails.Delete(stockId); } else { var stock = new StockReceived { AdminID = currMember.UseName, AdminInfo = currMember, DateEstablish = DateTime.Today, Deleted = false }; stockId = _stockRepository.Add(stock); } for (int i = 0; i < cardViewStockDetails.DataRowCount; i++) { var temp = cardViewStockDetails.GetRow(i) as StockReceivedDetail; temp.StockRecievedID = stockId; _managerStockedDetails.Insert(temp).GetErrorMessages(); } if (isNew) { xtraTabPage1.PageEnabled = true; isNew = false; btnAll.PerformClick(); } expandablePanel.PerformClick(); btnDetailsSave.Enabled = false; }
public ActionResult InsertOrUpdate(Course course) { var aResult = new ActionResult(); try { if (course.CourseID <= 0) { if (_repository.Find(e => e.Name.ToLower() == course.Name.ToLower()).Count() > 0) { aResult.Exceptions.Add(new Exception(String.Format("Category {0} had been exited!", course.Name))); } else if (_repository.Add(course) <= 0) { aResult.Exceptions.Add(new Exception("Inserted process had been failed!")); } } else { if (!_repository.Update(course)) { aResult.Exceptions.Add(new Exception("Updated process had been failed!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public ActionResult InsertOrUpdate(StockReceived stock) { var aResult = new ActionResult(); try { if (stock.ID <= 0) { if (!(_repository.Add(stock) > 0)) { aResult.Exceptions.Add(new Exception("Failse!")); } } else { if (!_repository.Update(stock)) { aResult.Exceptions.Add(new Exception("Failse!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public ActionResult InsertOrUpdate(Class _class) { var aResult = new ActionResult(); try { if (_class.CourseID <= 0) { if (_repository.Add(_class) <= 0) { aResult.Exceptions.Add(new Exception("Inserted process had been failed!")); } } else { if (!_repository.Update(_class)) { aResult.Exceptions.Add(new Exception("Updated process had been failed!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public ActionResult InsertOrUpdate(Member member) { var aResult = new ActionResult(); try { if (member.MemberID <= 0) { if (_repository.Add(member) <= 0) { aResult.Exceptions.Add(new Exception("Inserted process had been failed!")); } } else { if (!_repository.Update(member)) { aResult.Exceptions.Add(new Exception("Updated process had been failed!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public ActionResult InsertOrUpdate(Wage wage) { var aResult = new ActionResult(); try { if (wage.ID == 0) { if (!(_repository.Add(wage) > 0)) { aResult.Exceptions.Add(new Exception("Failse!")); } } else { if (!_repository.Update(wage)) { aResult.Exceptions.Add(new Exception("Failse!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public async Task <ActionResult <bool> > AddUserRole(UserRole ur) { if (ur != null) { try { generalRepository.Add <UserRole>(ur); if (await generalRepository.SaveChangesAsync()) { return(Ok(true)); } else { return(StatusCode(StatusCodes.Status500InternalServerError)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } } else { return(false); } }
public ActionResult InsertOrUpdate(Order order) { var aResult = new ActionResult(); try { if (order.ID <= 0) { if (!(_repository.Add(order) > 0)) { aResult.Exceptions.Add(new Exception("Failse!")); } } else { if (!_repository.Update(order)) { aResult.Exceptions.Add(new Exception("Failse!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public async Task <ActionResult <int> > RegisterUser(RegistrationModel userModel) { try { var user = mapper.Map <User>(userModel); user.RegistrationDate = DateTime.Now; user.IsActive = true; generalRepository.Add(user); await generalRepository.SaveChangesAsync(); user = await userRepository.GetUserByEmailAsync(user.Mail); var intResponse = userRoleRepository.AddUserRole(user.UserID); if (intResponse > 0) { if (await userRepository.ChangeCurrentUserRole(user.UserID, intResponse)) { return(Ok(user.UserID)); } else { return(StatusCode(StatusCodes.Status500InternalServerError)); } } else { return(StatusCode(StatusCodes.Status500InternalServerError)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public ActionResult InsertOrUpdate(Product pro) { var aResult = new ActionResult(); try { if (pro.ID <= 0) { if (!(_repository.Add(pro) > 0)) { aResult.Exceptions.Add(new Exception("Failse!")); } } else { if (!_repository.Update(pro)) { aResult.Exceptions.Add(new Exception("Failse!")); } } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public async Task <IActionResult> Post(StudentDto studentDto) { var student = _mapper.Map <Student>(studentDto); // if (student.CountryOfOrigin == null) // return NotFound(); _repo.Add(student); if (await _repo.SaveAll()) { var studentToReturn = _mapper.Map <StudentDto>(student); return(new CreatedAtRouteResult("GetStudent", new { id = student.Id }, studentToReturn)); } return(StatusCode(500, new { status = "error", message = "Error Occured please try again later, please try again later..." })); }
public ActionResult Insert(OrderDetail orderDetail) { var aResult = new ActionResult(); try { if (!(_repository.Add(orderDetail) > 0)) { aResult.Exceptions.Add(new Exception(String.Format("Insert order details (order id = {0}, product name = {1}) had been fail", orderDetail.OrderID, orderDetail.ProductInfo.Name))); } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public ActionResult Insert(StockReceivedDetail stockDetails) { var aResult = new ActionResult(); try { if (!(_repository.Add(stockDetails) > 0)) { aResult.Exceptions.Add(new Exception(String.Format("Insert stock details (stock id = {0}, product name = {1}) had been fail", stockDetails.StockRecievedID, stockDetails.ProductInfo.Name))); } } catch (Exception ex) { aResult.Exceptions.Add(ex); } return(aResult); }
public async Task <ActionResult <Delivery> > NewDelivery(Delivery newDelivery) { try { generalRepository.Add <Delivery>(newDelivery); var x = await generalRepository.SaveChangesAsync(); if (x) { return(Ok(newDelivery)); } else { return(StatusCode(StatusCodes.Status500InternalServerError)); } } catch (Exception ex) { Debug.WriteLine(ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
private void btnDetailsSave_ItemClick(object sender, ItemClickEventArgs e) { cardViewBillDetails.RefreshData(); cardViewBillDetails.RefreshData(); if (current != null && current.ID == 0) { current.Deleted = false; current.ID = _repBills.Add(current); for (int i = 0; i < cardViewBillDetails.DataRowCount; i++) { var detail = cardViewBillDetails.GetRow(i) as BillDetail; detail.BillID = current.ID; detail.OrderID = detail.OrderInfo.ID; detail.BillInfo = current; _repBillDetails.Add(detail); var order = _repOrders.GetById(detail.OrderID); order.Deleted = true; _repOrders.Update(order); } repOrders.DataSource = _repOrders.Find(or => or.Deleted == false).ToList(); } else { MessageBox.Show("This bill is not correct!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } btnDetailsAll.PerformClick(); isNew = false; btnDetailsNew.Enabled = false; btnShowBills.Enabled = true; btnDetailsSave.Enabled = false; }
public void AddAssetsGeneral(GeneralAttribute item) { _assetsGeneralRep.Add(item); }