public virtual ActionResult Edit(int id, int?parentId, HttpDelete ignore) { EntityT entityItem = null; using (new EFUnitOfWork <DbContextT>()) { try { entityItem = RepoFactory.Create <EntityT>().GetById(id); if (parentId == null) { var mvcModelItem = (ChildMvcModelT) new ChildMvcModelT().MapFromObject(entityItem); var parent = mvcModelItem.GetParentEntity(entityItem); if (parent != null) { parentId = parent.Id; } } entityItem.Delete(); } catch (UnableToDeleteException ex) { DbContextAmbientContext <DbContextT> .CurrentDbContext.CommitOnDispose = false; //rollback the transaction TempData.Supermodel().NextPageModalMessage = ex.Message; } catch (Exception) { DbContextAmbientContext <DbContextT> .CurrentDbContext.CommitOnDispose = false; //rollback the transaction TempData.Supermodel().NextPageModalMessage = "PROBLEM!!!\\n\\nUnable to delete. Most likely reason: references from other entities."; } } return(AfterDelete(id, parentId, entityItem)); }
public void CanDeleteAll() { Http.Stub( HttpDelete .Url("https://api.cronofy.com/v1/events") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBody("{\"delete_all\":true}") .ResponseCode(202) ); Client.DeleteAllEvents(); }
public void CanCloseChannel() { const string channelId = "chn_54cf7c7cb4ad4c1027000001"; Http.Stub( HttpDelete .Url("https://api.cronofy.com/v1/channels/" + channelId) .RequestHeader("Authorization", "Bearer " + AccessToken) .ResponseCode(202) ); Client.CloseChannel(channelId); }
public void CanDeleteExternalEvent() { const string eventUid = "external_event_id"; Http.Stub( HttpDelete .Url("https://api.cronofy.com/v1/calendars/" + calendarId + "/events") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat(@"{{""event_uid"":""{0}""}}", eventUid) .ResponseCode(202) ); Client.DeleteExternalEvent(calendarId, eventUid); }
public void CanDeleteAllForCalendars() { const string calendar1 = "cal_1234_5678"; const string calendar2 = "cal_8765_4321"; Http.Stub( HttpDelete .Url("https://api.cronofy.com/v1/events") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat("{{\"calendar_ids\":[\"{0}\",\"{1}\"]}}", calendar1, calendar2) .ResponseCode(202) ); Client.DeleteAllEventsForCalendars(calendar1, calendar2); }
public virtual ActionResult DeleteBinaryFile(int id, string pn, HttpDelete ignore) { using (new EFUnitOfWork <DbContextT>()) { var entityItem = RepoFactory.Create <EntityT>().GetById(id); var mvcModelItem = (MvcModelT) new MvcModelT().MapFromObject(entityItem); //see if pn is a required property if (Attribute.GetCustomAttribute(typeof(MvcModelT).GetProperty(pn), typeof(RequiredAttribute), true) != null) { TempData.Supermodel().NextPageModalMessage = "Cannot delete required field"; var routeValues = new RouteValueDictionary(ControllerContext.RouteData.Values); routeValues["Action"] = "Edit"; return(RedirectToRoute(routeValues)); } var file = (BinaryFileMvcModel)mvcModelItem.PropertyGet(pn); file.Empty(); entityItem = (EntityT)mvcModelItem.MapToObject(entityItem); return(AfterBinaryDelete(id, entityItem, mvcModelItem)); } }
public virtual ActionResult Edit(int id, HttpDelete ignore) { EntityT entityItem = null; using (new EFUnitOfWork <DbContextT>()) { try { entityItem = RepoFactory.Create <EntityT>().GetById(id); entityItem.Delete(); } catch (UnableToDeleteException ex) { DbContextAmbientContext <DbContextT> .CurrentDbContext.CommitOnDispose = false; //rollback the transaction TempData.Supermodel().NextPageModalMessage = ex.Message; } catch (Exception) { DbContextAmbientContext <DbContextT> .CurrentDbContext.CommitOnDispose = false; //rollback the transaction TempData.Supermodel().NextPageModalMessage = "PROBLEM!!!\\n\\nUnable to delete. Most likely reason: references from other entities."; } } return(AfterDelete(id, entityItem)); }