Exemple #1
0
        public ActionResult Create(PersonViewModel obj)
        {
            try
            {
                Person s = new Person();
                s.PersonId          = obj.PersonId;
                s.FirstName         = obj.FirstName;
                s.MiddleName        = obj.MiddleName;
                s.LastName          = obj.LastName;
                s.DateOfBirth       = obj.DateOfBirth;
                s.AddedOn           = obj.AddedOn;
                s.AddedBy           = obj.AddedBy;
                s.HomeAddress       = obj.HomeAddress;
                s.HomeCity          = obj.HomeCity;
                s.FaceBookAccountId = obj.FaceBookAccountId;
                s.LinkedInId        = obj.LinkedInId;
                s.UpdateOn          = obj.UpdateOn;
                s.TwitterId         = obj.TwitterId;
                s.EmailId           = obj.EmailId;

                PhoneBookDbEntities4 db = new PhoneBookDbEntities4();
                db.People.Add(s);
                db.SaveChanges();
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        public ActionResult Create(ContactViewModel obj)
        {
            try
            {
                Contact s = new Contact();
                s.ContactId     = obj.ContactId;
                s.ContactNumber = obj.ContactNumber;
                s.Type          = obj.Type;
                s.PersonId      = obj.PersonId;

                PhoneBookDbEntities4 db = new PhoneBookDbEntities4();
                db.Contacts.Add(s);
                db.SaveChanges();
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }