public ActionResult Delete(ActivityViewModel model) { try { var oldData = _actLogic.GetById(model.Id); var response = _actLogic.Delete(model.Id);; if (response.IsError == true) { foreach (var item in response.ErrorCodes) { ModelState.AddModelError(string.Empty, item); } var result = _actLogic.GetById(model.Id); ActivityViewModel act = new ActivityViewModel() { Id = result.Id, Title = result.Title, Budget = result.Budget, Date = result.Date.ToString("mm-dd-yyyy"), Description = result.Description, OPDId = result.OPDId }; return(View(result)); } return(RedirectToAction("View", "OPD", new { id = oldData.OPDId })); } catch { return(View()); } }
private void m_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripItem item = e.ClickedItem; string itemName = item.ToString(); if (itemName == "Izbriši") { ActivityLogic.Delete(activityBindingSource.Current as Activity); ShowActivities(); } }
public async Task <int> Delete(long id) { AzureStorageService azureStorageService = serviceProvider.GetService <AzureStorageService>(); Activity model = await ActivityLogic.ReadById(id); if (model.Attachments != null) { foreach (ActivityAttachment attachment in model.Attachments) { await azureStorageService.DeleteImage("Activity", attachment.FilePath); } } await ActivityLogic.Delete(id); return(await DbContext.SaveChangesAsync()); }
public void ActivityLogic() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); Mock <IActivityRepository> repo = new Mock <IActivityRepository>(); Mock <ITeamLogic> teamLogic = new Mock <ITeamLogic>(); ActivityLogic logic = new ActivityLogic(uow.Object, repo.Object, teamLogic.Object); var activity = new Activity(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(activity)); repo.InSequence(sequence).Setup(r => r.Update(activity)); repo.InSequence(sequence).Setup(r => r.Get(activity.Id)); repo.InSequence(sequence).Setup(r => r.Delete(activity.Id)); logic.Create(activity); logic.Update(activity); logic.Get(activity.Id); logic.Delete(activity.Id); }
public async Task <int> Delete(long id) { long stageId = this.DbSet.Single(p => p.Id == id).StageId; HashSet <long> activitiesId = new HashSet <long>(this.DbContext.DealTrackingActivities .Where(p => p.DealId.Equals(id)) .Select(p => p.Id)); List <Task> tasks = new List <Task>(); foreach (long activityId in activitiesId) { tasks.Add(ActivityLogic.Delete(activityId)); } await Task.WhenAll(); await DealLogic.Delete(id); StageLogic.UpdateDealsOrderDelete(stageId, id); return(await DbContext.SaveChangesAsync()); }