public void UpdateExpense(ExpenseViewModel expense) { var expenseToRemove = _expenseRepository.GetById(expense.ExpenseC); var updateCustomer = Mapper.Map <ExpenseViewModel, Expense_M>(expense); _expenseRepository.Delete(expenseToRemove); _expenseRepository.Add(updateCustomer); _locationDetailRepository.Query(p => p.ExpenseC == expense.ExpenseC).ToList().ForEach(l => l.ExpenseN = expense.ExpenseN); SaveExpense(); }
private void tsbCancel_Click(object sender, EventArgs e) { if (formMode == FormMode.Add) { expenseRepository.Delete(lblCode.Text); } GetLastExpense(); DisableForm(); formMode = FormMode.View; this.Text = "Biaya"; }
public Message Delete(Expense expense) { Message msg = new Message(); try { var model = _expenseRepository.FindBy(x => x.Id == expense.Id).FirstOrDefault(); if (model == null) { throw new ArgumentException(); } expense.ToDalEntity(model); _expenseRepository.Delete(model); _expenseRepository.SaveChanges(); msg.StatusCode = 200; msg.Status = "Expense Deleted Successfully!"; } catch (Exception ex) { msg.StatusCode = 400; msg.Status = "There was an error deleting expense."; } return(msg); }
public ICommandResult Execute(DeleteExpenseCommand command) { var expense = expenseRepository.GetById(command.ExpenseId); expenseRepository.Delete(expense); unitOfWork.Commit(); return(new CommandResult(true)); }
public async Task <IActionResult> Delete(int id) { var expense = await _expenseRepository.GetById(id); await _expenseRepository.Delete(expense); return(Ok(new MessageResult("Item deleted"))); }
public async Task <IActionResult> DeleteExpense(int idExpense) { if (await _expenseRepository.Delete(idExpense)) { return(Ok()); } return(BadRequest()); }
public void DeleteById() { if (this.Id <= 0) { throw new ArgumentException("Expense id should be greater than zero"); } _expenseRepository.Delete(this.Id); _expenseMongoRepository.RemoveDocumentByExpenseId(this.Id); }
public List <Expense> DeleteExpenses(string userId, List <int> idsToDelete) { var expenses = _expenseRepository.Find(userId, idsToDelete).ToList(); expenses.ForEach(n => _expenseRepository.Delete(n)); _unitOfWork.Save(); return(expenses); }
private async void RemoveExpenseCollection(ExpenseCollectionModel model) { if (model == ActiveCollection) { var index = ExpenseCollections.IndexOf(ActiveCollection); if (index == 0) { ActiveCollection = ExpenseCollections[1]; } else { ActiveCollection = ExpenseCollections[--index]; } } await _expenseRepository.Delete(model); RaisePropertyChanged(() => TotalExpenseAmount); Messenger.Default.Send(Messages.ExpenseChanged); }
public async Task <ActionResult <Expense> > DeleteExpense(int id) { var expense = await _repository.Delete(id); if (expense == null) { return(NotFound()); } return(expense); }
public ActionResult Delete(int expenseID) { Expense deletedExpense = repository.Delete(expenseID); if (deletedExpense != null) { TempData["message"] = string.Format("Usunięto {0} z dnia {1}", deletedExpense.Description, deletedExpense.Date.ToString("d")); } return(RedirectToAction("Index")); }
public void DeleteExpense(int id) { var Expense = _ExpenseRepository.GetById(id); var ExpenseDetails = Mapper.Map <ExpenseDetails>(Expense); _ExpenseRepository.Delete(Expense); var strategy = ContextMovementStrategy.GetMovementStrategy(new Movement(ExpenseDetails), _bankAccountRepository, _historicMovementRepository, _incomeRepository, _atmWithdrawRepository); strategy.Credit(); }
public IActionResult Delete(int id) { var expense = _expenseRepository.Find(id); if (expense == null) { return(NotFound()); } _expenseRepository.Delete(id); return(new NoContentResult()); }
public async Task <bool> Handle(DeleteExpenseCommand request, CancellationToken cancellationToken) { var expenseFromRepo = await _expenseRepository.RetrieveById(request.ExpenseId); if (expenseFromRepo == null) { throw new NotFoundException(nameof(Expense), request.ExpenseId); } _expenseRepository.Delete(expenseFromRepo); return(await _unitOfWorkRepository.SaveChanges() > 0); }
public IActionResult DeleteExpense(int id) { var expense = expenseRepo.GetById(id); var projectId = expense.ProjectId; expenseRepo.Delete(id); var project = projectRepo.GetById(projectId); project.ProjectTotalExpenses = expenseRepo.ExpenseTotal(project); expenseRepo.Save(); return(RedirectToAction("Details", "Projects", new { Id = projectId })); }
public IActionResult Delete(int expenseId) { Account s = _saveRepo.Accounts.Where(x => x.TypeID == _saveTypeRepo.AccountTypes.Where(y => y.Name.Equals("Personal")).FirstOrDefault().ID).FirstOrDefault(); Expense deletedExpense = _repo.Delete(expenseId); s.Amount = Math.Round(s.Amount + deletedExpense.Amount, 2); _saveRepo.Save(s); if (deletedExpense != null) { TempData["message"] = $"{deletedExpense.Description} was deleted"; } return(RedirectToAction("MonthlyReport")); }
public Task <bool> Handle(RemoveExpenseCommand command) { var entity = _expenseRepository.Get(command.Id); if (entity == null) { AddNotification("despesa", "Despesa não localizada"); return(Task.FromResult(false)); } _expenseRepository.Delete(entity); _uow.Commit(); return(Task.FromResult(true)); }
public Task <bool> RemoveExpense(ExpenseObject obj) { return(Task.Run(() => { try { if (obj.Id != Guid.Empty) { expenseRepo.Delete(obj.Id); } expenseRepo.UnitofWork.Commit(); return true; } catch (Exception ex) { throw ex; } })); }
public IActionResult Delete(int Id) { if (string.IsNullOrEmpty(User.Identity.Name)) { userName = "******"; } else { userName = User.Identity.Name; } Expense expense = _expenseRepository.GetExpenseById(Id, userName); if (expense == null) { Response.StatusCode = 404; ViewBag.ErrorMessage = $"Expense with Id = {Id} cannot be found"; return(View("NotFound")); } Expense expenseDeleted = _expenseRepository.Delete(Id, userName); return(RedirectToAction("Index")); }
public IHttpActionResult Delete(int id) { try { var result = _repository.Delete(id); if (result.Status == RepositoryActionStatus.Deleted) { return(StatusCode(HttpStatusCode.NoContent)); } else if (result.Status == RepositoryActionStatus.NotFound) { return(NotFound()); } return(BadRequest()); } catch (Exception) { return(InternalServerError()); } }
public IActionResult Delete(int expenseId) { _repository.Delete(expenseId); return(RedirectToAction(nameof(List))); }
public ActionResult DeleteConfirmed(int id) { _expenseRepository.Delete(id); return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int id, ExpenseModel expenseModel) { _expenseRepository.Delete(id); return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(Guid id) { var result = _repo.Delete(id); return(Ok(result)); }
public void DeleteExpense(int expenseId) { _expenseRepository.Delete(expenseId); }
public void Delete(int id) { logger.Info($"Deleting Expense with Id: {id}"); _expenseRepository.Delete(id); }
public async Task <int> Delete(int id) { return(await _expenseRepository.Delete(id)); }
public void DeleteExpense(Expense expense) { _expenseRepository.Delete(expense); }
//User request to quit home public async Task LeaveHomeAsync(UserModel user, int newAdminId) { if (user.Position == (int)UserPosition.HasNotHome) { CustomException errors = new CustomException((int)HttpStatusCode.BadRequest); errors.AddError("Home Not Exist", "User is not member of a home"); errors.Throw(); } Task <InformationModel> firstNameInfo = _informationRepository.GetInformationByInformationNameAsync("FirstName"); Task <InformationModel> lastNameInfo = _informationRepository.GetInformationByInformationNameAsync("LastName"); user = await _userRepository.GetByIdAsync(user.Id, true); HomeModel home = await _homeRepository.GetByIdAsync(user.Home.Id, true); UserInformationModel userFirstName = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, (await firstNameInfo).Id); UserInformationModel userLastName = await _userInformationRepository.GetUserInformationByIdAsync(user.Id, (await lastNameInfo).Id); List <UserExpenseModel> userExpenses = await _userExpenseRepository.GetAllUserExpenseByUserIdAsync(user.Id); foreach (var ue in userExpenses) { _userExpenseRepository.Delete(ue); } if (home.Users.Count != 1) { if (user.Position == (int)UserPosition.Admin) { UserModel newAdmin = await _userRepository.GetByIdAsync(newAdminId); if (newAdmin == null || newAdmin.Home.Id != user.Home.Id) { CustomException errors = new CustomException((int)HttpStatusCode.BadRequest); errors.AddError("Friendship Not Found", "Friendship not found for admin assignment"); errors.Throw(); } newAdmin.Position = (int)UserPosition.Admin; home.Admin = newAdmin; } home.Users.Remove(user); user.Home = null; user.Position = (int)UserPosition.HasNotHome; _homeRepository.Update(home); _userRepository.Update(user); //Home friends notification foreach (var u in home.Users) { FriendshipModel friendship = await _friendshipRepository.GetFriendshipByIdAsync(user.Id, u.Id); FCMModel fcm = new FCMModel(u.DeviceId, new Dictionary <string, object>()); fcm.notification.Add("title", "Evden Ayrılma"); if (friendship.User1.Id == user.Id) { if (friendship.Debt > 0) { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Alacağınız : {2:c}", userFirstName.Value, userLastName.Value, friendship.Debt)); } else if (friendship.Debt == 0) { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Borcunuz veya alacağınız bulunmamaktadır.", userFirstName.Value, userLastName.Value)); } else { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Borcunuz : {2:c}", userFirstName.Value, userLastName.Value, -friendship.Debt)); } } else { if (friendship.Debt > 0) { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Borcunuz : {2:c}", userFirstName.Value, userLastName.Value, friendship.Debt)); } else if (friendship.Debt == 0) { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Borcunuz veya alacağınız bulunmamaktadır.", userFirstName.Value, userLastName.Value)); } else { fcm.notification.Add("body", String.Format("{0} {1} evden ayrılıyor. Alacağınız : {2:c}", userFirstName.Value, userLastName.Value, -friendship.Debt)); } } await _fcmService.SendFCMAsync(fcm); fcm = new FCMModel(u.DeviceId, type: "LeaveHome"); fcm.data.Add("LeaverId", user.Id); await _fcmService.SendFCMAsync(fcm); _friendshipRepository.Delete(friendship); } } else { ShoppingListModel shoppingList = await _shoppingListRepository.GetShoppingListByHomeIdAsync(user.Home.Id); List <NotepadModel> notepad = await _notepadRepository.GetAllNoteByHomeIdAsync(user.Home.Id); List <ExpenseModel> expenses = await _expenseRepository.GetAllExpensesByHomeIdAsync(user.Home.Id); _shoppingListRepository.Delete(shoppingList); foreach (var note in notepad) { _notepadRepository.Delete(note); } foreach (var expense in expenses) { _expenseRepository.Delete(expense); } user.Home = null; user.Position = (int)UserPosition.HasNotHome; _userRepository.Update(user); _homeRepository.Delete(home); } }
public void Delete(ExpenseDTO expenseDTO) { expenseRepository.Delete(expense_dtoToModel(expenseDTO)); }