public IHttpActionResult PostContact(ContactRegister contact)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            try
            {
                var objContact = this._objContact.ContactRegisterInsert(contact);
            }
            catch (ApplicationException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message
                });
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message
                });
            }

            return(CreatedAtRoute("DefaultApi", new { id = contact.ContactId }, contact));
        }
        public IHttpActionResult GetContact(int id)
        {
            ContactRegister contactDetail = new ContactRegister();

            try
            {
                contactDetail = _objContact.ContactRegisterGet().Where(E => E.ContactId == id).FirstOrDefault();
            }
            catch (ApplicationException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message
                });
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message
                });
            }

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

            return(Ok(contactDetail));
        }
Esempio n. 3
0
        public string ContactRegisterInsert(ContactRegister contact)
        {
            this.unitOfWork.GetContactRegisterRepository.Insert(contact);
            int insertData = this.unitOfWork.Save();

            if (insertData > 0)
            {
                return("Successfully Inserted contact records");
            }
            else
            {
                return("Insertion faild");
            }
        }
        public IHttpActionResult PutContact(int id, ContactRegister contact)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != contact.ContactId)
            {
                return(BadRequest());
            }


            try
            {
                if (!ContactExists(id))
                {
                    return(NotFound());
                }

                var objContact = this._objContact.ContactRegisterUpdate(contact);
            }
            catch (ApplicationException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message
                });
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message
                });
            }



            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 5
0
        static Contact()
        {
            Register(ShapeType.Circle, ShapeType.Circle, CircleContact.Create, CircleContact.Destroy);
            Register(ShapeType.Polygon, ShapeType.Circle, PolygonAndCircleContact.Create, PolygonAndCircleContact.Destroy);
            Register(ShapeType.Polygon, ShapeType.Polygon, PolygonContact.Create, PolygonContact.Destroy);
            Register(ShapeType.Edge, ShapeType.Circle, EdgeAndCircleContact.Create, EdgeAndCircleContact.Destroy);
            Register(ShapeType.Edge, ShapeType.Polygon, EdgeAndPolygonContact.Create, EdgeAndPolygonContact.Destroy);
            Register(ShapeType.Chain, ShapeType.Circle, ChainAndCircleContact.Create, ChainAndCircleContact.Destroy);
            Register(ShapeType.Chain, ShapeType.Polygon, ChainAndPolygonContact.Create, ChainAndPolygonContact.Destroy);

            void Register(ShapeType type1, ShapeType type2, CreateContact createFunc, DestroyContact destroyFunc)
            {
                Debug.Assert(0 <= type1 && type1 < ShapeType.TypeCount);
                Debug.Assert(0 <= type2 && type2 < ShapeType.TypeCount);

                _registers[(int)type1, (int)type2] = new ContactRegister(createFunc, destroyFunc, true);
                if (type1 != type2)
                {
                    _registers[(int)type2, (int)type1] = new ContactRegister(createFunc, destroyFunc, false);
                }
            }
        }
Esempio n. 6
0
        public string ContactRegisterUpdate(ContactRegister contact)
        {
            objContactRegister = unitOfWork.GetContactRegisterRepository.GetByID(contact.ContactId);

            if (objContactRegister != null)
            {
                objContactRegister.FirstName     = contact.FirstName;
                objContactRegister.LastName      = contact.LastName;
                objContactRegister.PhoneNumber   = contact.PhoneNumber;
                objContactRegister.Email         = contact.Email;
                objContactRegister.ContactStatus = contact.ContactStatus;
            }
            this.unitOfWork.GetContactRegisterRepository.Attach(objContactRegister);
            int result = this.unitOfWork.Save();

            if (result > 0)
            {
                return("Sucessfully updated contact records");
            }
            else
            {
                return("Updation faild");
            }
        }
Esempio n. 7
0
 public string ContactRegisterUpdate(ContactRegister contact)
 {
     return("updated");
 }
Esempio n. 8
0
 public string ContactRegisterInsert(ContactRegister contact)
 {
     return("inserted");
 }