Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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();
     }));
 }