Example #1
0
        public IHttpActionResult GetVolunteer(int id)
        {
            Volunteer volunteer = db.Volunteers.Find(id);

            if (volunteer == null)
            {
                return(NotFound());
            }
            DTO_Volunteer dvolunteer = new DTO_Volunteer();

            volunteer.ConvertToDTO(dvolunteer);

            return(Ok(dvolunteer));
        }
Example #2
0
        public IHttpActionResult GetLogin(string id, string id2)
        {
            Custom_Validation cval = new Custom_Validation();

            cval.Volunteers = db.Volunteers.ToList();
            cval.Users      = db.Users.ToList();
            cval.Drivers    = db.Drivers.ToList();

            var obj = cval.Login_Validation(id, id2);

            if (obj is Volunteer)
            {
                Volunteer     vol     = obj as Volunteer;
                DTO_Volunteer dto_vol = new DTO_Volunteer();
                vol.ConvertToDTO(dto_vol);
                return(Ok(new { obj = dto_vol, type = "volunteer" }));
            }
            else if (obj is User)
            {
                User     vol      = obj as User;
                DTO_User dto_user = new DTO_User();
                vol.ConvertToDTO(dto_user);
                return(Ok(new { obj = dto_user, type = "user" }));
            }
            else if (obj is Driver)
            {
                Driver     dri     = obj as Driver;
                DTO_Driver dto_dri = new DTO_Driver();
                dri.ConvertToDTO(dto_dri);
                return(Ok(new { obj = dto_dri, type = "driver" }));
            }
            else
            {
                return(Ok("Error"));
            }
        }