internal static bool GatheringItemInEquality(GatheringItemIn x, GatheringItemIn y) { return (x.City == y.City && x.details == y.details && x.occurrenceData == y.details && x.Title == y.Title); }
public async Task AddGathering(string username, string password, GatheringItemIn gathering) { if (!await Logic.CheckAdmin(Output, username, password)) { throw new Exception("403", new Exception("this request must be made with admin permitions")); } if (null != await Output.GetFind <Gathering>(x => x.Title == gathering.Title)) { throw new Exception("409", new Exception("A gathering of this title allready exists")); } var inGathering = gathering.ToData(); inGathering.MapDataId = await Logic.CityId(Output, gathering.City); inGathering.organizerId = (await Logic.Login(Output, username, password)).Id; await Input.Add(inGathering); }
public async Task EditGatheringInfo(string username, string password, string formerTitle, GatheringItemIn gathering) { var subject = await Output.GetFind <Gathering>(x => x.Title == formerTitle); if (subject == null) { throw new Exception("404", new Exception("subject cannot be found")); } if (subject.organizer.Username != (await Logic.Login(Output, username, password)).Username) { throw new Exception("403", new Exception("only the orginizer can edit the gathering item")); } if (null != await Output.GetFind <Gathering>(x => x.Title == gathering.Title)) { throw new Exception("409", new Exception("given title \"" + gathering.Title + "\" is allready used")); } subject.MapDataId = await Logic.CityId(Output, gathering.City); subject.Title = gathering.Title; subject.occurrenceData = gathering.occurrenceData; subject.details = gathering.occurrenceData; await Input.Set(subject, subject.id); }
public async Task <ActionResult> AddGathering(string username, string password, [FromBody] GatheringItemIn input) { return(await TryTask.Run(async() => { await Post.AddGathering(username, password, input); return NoContent(); })); }