Exemplo n.º 1
0
        public async Task <List <InvitationModel> > GetInvitationsByUserInvitor(int userid)
        {
            var dataContext = new HambasafeDataContext();
            var invitations = Mapper.Map <List <Invitation>, List <InvitationModel> >(dataContext.Invitations.Where(e => e.InvitorUserId == userid).ToList());

            return(invitations);
        }
Exemplo n.º 2
0
 public async Task <HttpResponseMessage> GetAllLocations()
 {
     try
     {
         var dataContext = new HambasafeDataContext();
         return(Request.CreateResponse(HttpStatusCode.OK, dataContext.EventLocations.ToList().Select(l => new models.EventLocation(l))));
     }
     catch (Exception error)
     {
         return(HandleError(error));
     }
 }
Exemplo n.º 3
0
 public async Task <HttpResponseMessage> GetLocation(int id)
 {
     try
     {
         var dataContext = new HambasafeDataContext();
         return(Request.CreateResponse(HttpStatusCode.OK, dataContext.EventLocations.ToList()
                                       .Where(l => l.EventLocationId == id)));
     }
     catch (Exception error)
     {
         return(HandleError(error));
     }
 }
Exemplo n.º 4
0
        public async Task <HttpResponseMessage> GetEventsByUser(int userid)
        {
            try
            {
                var dataContext = new HambasafeDataContext();
                var events      = dataContext.Events.ToList().Where(e => e.OwnerUserId == userid).Select(e => new EventModel(e));

                return(Request.CreateResponse(HttpStatusCode.OK, events));
            }
            catch (Exception error)
            {
                return(HandleError(error));
            }
        }
Exemplo n.º 5
0
        public async Task <HttpResponseMessage> GetEventTypes()
        {
            HambasafeDataContext context = new HambasafeDataContext();

            try
            {
                var eventTypes = context.EventTypes.ToList().Select(et => new EventTypeModel(et));

                return(Request.CreateResponse(HttpStatusCode.OK, eventTypes));
            }
            catch (Exception error)
            {
                return(HandleError(error));
            }
        }
Exemplo n.º 6
0
        public async Task <HttpResponseMessage> GetEventsByCoordinates(double latitude, double longitude, int radius)
        {
            try
            {
                HambasafeDataContext context = new HambasafeDataContext();

                //TODO implement
                //var matchingLocations = context.Location

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception error)
            {
                return(HandleError(error));
            }
        }
Exemplo n.º 7
0
        public async Task <HttpResponseMessage> CreateEvent(EventModel eventModel)
        {
            try
            {
                var dataContext = new HambasafeDataContext();

                var eventEntity = new Event()
                {
                    Name = eventModel.Name,
                };

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception error)
            {
                return(HandleError(error));
            }
        }
Exemplo n.º 8
0
        public async Task <HttpStatusCode> CreateInvitation(InvitationModel invitationModel)
        {
            var dataContext = new HambasafeDataContext();

            var invitationEntity = new Invitation()
            {
                InvitorUserId        = invitationModel.InvitorUserId,
                InviteeUserId        = invitationModel.InviteeUserId,
                EventId              = invitationModel.EventId,
                OptionalEmailInvitee = invitationModel.OptionalEmailInvitee,
                Status  = invitationModel.Status,
                Comment = invitationModel.Comment
            };

            dataContext.Invitations.Add(invitationEntity);
            await dataContext.SaveChangesAsync();

            return(HttpStatusCode.OK);
        }
Exemplo n.º 9
0
        public async Task <HttpResponseMessage> Register(RegisterModel registerModel)
        {
            try
            {
                var dataContext = new HambasafeDataContext();

                // Create new user
                var User = new User()
                {
                    FirstNames    = registerModel.FirstNames,
                    LastName      = registerModel.LastName,
                    Gender        = registerModel.Gender,
                    DateOfBirth   = registerModel.DateOfBirth,
                    Status        = "created",
                    MobileNumber  = registerModel.MobileNumber,
                    EmailAddress  = registerModel.EmailAddress,
                    DateCreated   = new DateTime(),
                    DateLastLogin = new DateTime()
                };

                // Create the token
                var    key = Encoding.UTF8.GetBytes(registerModel.Password.ToUpper());
                string hashString;

                //using (var hmac = new HMACSHA256(key))
                //{
                //    var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes());
                //    hashString = Convert.ToBase64String(hash);
                //}

                //return hashString;



                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception error)
            {
                return(HandleError(error));
            }
        }
Exemplo n.º 10
0
 public EfRepository(HambasafeDataContext dbContext)
 {
     DbContext = dbContext;
 }