Esempio n. 1
0
        public async Task <IHttpActionResult> DeleteCommunityEmergencyContacts(int id)
        {
            CommunityEmergencyContacts communityEmergencyContacts = await db.CommunityEmergencyContacts.FindAsync(id);

            if (communityEmergencyContacts == null)
            {
                return(NotFound());
            }

            db.CommunityEmergencyContacts.Remove(communityEmergencyContacts);
            await db.SaveChangesAsync();

            return(Ok(communityEmergencyContacts));
        }
Esempio n. 2
0
        public async Task <Response <CommunityEmergencyContacts> > GetCommunityEmergencyContacts(int id)
        {
            Response <CommunityEmergencyContacts> responceCommunityEmergencyContacts = new Response <CommunityEmergencyContacts>();
            CommunityEmergencyContacts            communityEmergencyContacts         = await db.CommunityEmergencyContacts.FindAsync(id);

            if (communityEmergencyContacts == null)
            {
                responceCommunityEmergencyContacts.status = "Failed: Emergency Contact did not found";
                responceCommunityEmergencyContacts.model  = null;
                return(responceCommunityEmergencyContacts);
            }

            responceCommunityEmergencyContacts.status = "Success";
            responceCommunityEmergencyContacts.model  = communityEmergencyContacts;
            return(responceCommunityEmergencyContacts);
        }
Esempio n. 3
0
        public async Task <Response <CommunityEmergencyContacts> > PostCommunityEmergencyContacts(CommunityEmergencyContacts communityEmergencyContacts)
        {
            Response <CommunityEmergencyContacts> responceCommunityEmergencyContacts = new Response <CommunityEmergencyContacts>();

            if (!ModelState.IsValid)
            {
                responceCommunityEmergencyContacts.status = "Failure";
                responceCommunityEmergencyContacts.model  = null;
                return(responceCommunityEmergencyContacts);
            }

            db.CommunityEmergencyContacts.Add(communityEmergencyContacts);
            await db.SaveChangesAsync();

            responceCommunityEmergencyContacts.status = "Success";
            responceCommunityEmergencyContacts.model  = communityEmergencyContacts;
            return(responceCommunityEmergencyContacts);
        }
Esempio n. 4
0
        public async Task <Response <CommunityEmergencyContacts> > PutCommunityEmergencyContacts(int id, CommunityEmergencyContacts communityEmergencyContacts)
        {
            Response <CommunityEmergencyContacts> responceCommunityEmergencyContacts = new Response <CommunityEmergencyContacts>();

            if (!ModelState.IsValid)
            {
                responceCommunityEmergencyContacts.status = "Failure";
                responceCommunityEmergencyContacts.model  = null;
                return(responceCommunityEmergencyContacts);
            }

            if (id != communityEmergencyContacts.id)
            {
                responceCommunityEmergencyContacts.status = "Failed: ID did not Match";
                responceCommunityEmergencyContacts.model  = null;
                return(responceCommunityEmergencyContacts);
            }

            db.Entry(communityEmergencyContacts).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommunityEmergencyContactsExists(id))
                {
                    responceCommunityEmergencyContacts.status = "Failed: ID did not Exist";
                    responceCommunityEmergencyContacts.model  = null;
                    return(responceCommunityEmergencyContacts);
                }
                else
                {
                    responceCommunityEmergencyContacts.status = "Failed: DB Update Exception";
                    responceCommunityEmergencyContacts.model  = null;
                    return(responceCommunityEmergencyContacts);
                }
            }
            responceCommunityEmergencyContacts.status = "Success";
            responceCommunityEmergencyContacts.model  = communityEmergencyContacts;
            return(responceCommunityEmergencyContacts);
        }