public async Task <IActionResult> PutExpenseType(int id, ExpenseTypeDTO expenseTypeDTO) { if (id != expenseTypeDTO.Id) { return(Conflict(new RespStatus { Status = "Failure", Message = "Id is invalid" })); } var expType = await _context.ExpenseTypes.FindAsync(id); expType.ExpenseTypeName = expenseTypeDTO.ExpenseTypeName; expType.ExpenseTypeDesc = expenseTypeDTO.ExpenseTypeDesc; expType.StatusTypeId = expenseTypeDTO.StatusTypeId; _context.ExpenseTypes.Update(expType); //_context.Entry(expenseType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(Ok(new RespStatus { Status = "Success", Message = "Expsense Type Details Updated!" })); }
private void OnDeleteExpenseTypeConfirmEventRaised(object sender, EventArgs e) { ExpenseTypeDTO expenseTypeDTO = (ExpenseTypeDTO)_expenseTypeDtoBindingSource.Current; _expenseTypeService.Delete(expenseTypeDTO); LoadAllExpensesFromDbToGrid(); }
private IExpenseTypeModel expenseType_dtoToModel(ExpenseTypeDTO dto) { ExpenseTypeModel model = new ExpenseTypeModel(); model.ExpenseTypeId = dto.ExpenseTypeId; model.ExpenseTypeName = dto.ExpenseTypeName; return(model); }
private ExpenseTypeDTO expenseType_modelToDto(IExpenseTypeModel expenseTypeModel) { ExpenseTypeDTO dto = new ExpenseTypeDTO(); dto.ExpenseTypeId = expenseTypeModel.ExpenseTypeId; dto.ExpenseTypeName = expenseTypeModel.ExpenseTypeName; return(dto); }
public static ExpenseType MapExpenseTypeDTOToExpenseType(ExpenseTypeDTO expenseType) { return(new ExpenseType { id = expenseType.id, name = expenseType.Typ }); }
private void OnExpenseTypeEditConfirmEventRaised(object sender, ExpenseTypeEditViewModel args) { ExpenseTypeDTO expenseTypeDTO = (ExpenseTypeDTO)_expenseTypeDtoBindingSource.Current; expenseTypeDTO.ExpenseTypeName = args.ExpenseTypeName; _expenseTypeService.Update(expenseTypeDTO); LoadAllExpensesFromDbToGrid(); }
public int AddExpenseType(ExpenseTypeDTO expenseType) { int result; string insertQuery = "INSERT INTO typer (Typ) " + "VALUES (@Typ);"; using (IDbConnection db = new MySqlConnection(connectionString)) { result = db.Execute(insertQuery, new { expenseType.Typ }); } return(result); }
private void OnExpenseTypeAddConfirmEventRaised(object sender, ExpenseTypeAddViewModel e) { try { ExpenseTypeDTO dto = new ExpenseTypeDTO(); dto.ExpenseTypeName = e.ExpenseTypeName; _expenseTypeService.Create(dto); _expenseTypeListPresenter.LoadAllExpensesFromDbToGrid(); _expenseStatisticsPresenter.Refresh(); } catch (DataAccessException ex) { EventHelpers.RaiseEvent(this, DataAccessExceptionEvent, ex); } }
public async Task <ActionResult <ExpenseType> > PostExpenseType(ExpenseTypeDTO expenseTypeDTO) { var eType = _context.ExpenseTypes.Where(e => e.ExpenseTypeName == expenseTypeDTO.ExpenseTypeName).FirstOrDefault(); if (eType != null) { return(Conflict(new RespStatus { Status = "Failure", Message = "Expense Type Already Exists" })); } ExpenseType expenseType = new(); expenseType.ExpenseTypeName = expenseTypeDTO.ExpenseTypeName; expenseType.ExpenseTypeDesc = expenseTypeDTO.ExpenseTypeDesc; expenseType.StatusTypeId = expenseTypeDTO.StatusTypeId; _context.ExpenseTypes.Add(expenseType); await _context.SaveChangesAsync(); return(Ok(new RespStatus { Status = "Success", Message = "Expense Type Created!" })); }
public void OnDeleteExpenseTypeEventRaised(object sender, EventArgs e) { ExpenseTypeDTO expenseDTO = (ExpenseTypeDTO)_expenseTypeDtoBindingSource.Current; _expenseTypeDeleteView.ShowExpenseTypeDeleteView(); }
public void Update(ExpenseTypeDTO expenseTypeDTO) { expenseTypeRepository.Update(expenseType_dtoToModel(expenseTypeDTO)); }
public void Delete(ExpenseTypeDTO expenseTypeDTO) { expenseTypeRepository.Delete(expenseType_dtoToModel(expenseTypeDTO)); }
public IEnumerable <ExpenseDTO> GetAllByUserIdAndExpenseType(int UserId, ExpenseTypeDTO expenseTypeDTO) { return(expenseRepository.GetAllByUserIdAndExpenseType(UserId, expenseType_dtoToModel(expenseTypeDTO)).Select(item => expense_modelToDto(item)).ToList()); }
public void ShowExpenseTypeEditView(ExpenseTypeDTO expenseDTO) { this.ShowDialog(); }