예제 #1
0
        public void New(string firstName, string lastName)
        {
            using (var ctx = new AccContexts())
            {
                base.New((int)enums.entityType.Person);

                var checkDuplication = ctx.person.Where(x => x.firstName == firstName && x.lastName == lastName).FirstOrDefault();
                if (checkDuplication != null)
                {
                    throw new Exception("Person Duplicated");
                }

                var newPerson = new AccountingLib.Models.person()
                {
                    firstName = firstName,
                    lastName  = lastName,
                    entityID  = base.ENTITYID
                };
                ctx.person.AddObject(newPerson);
                ctx.SaveChanges();

                this.id        = newPerson.ID;
                this.firstname = newPerson.firstName;
                this.lastname  = newPerson.lastName;
            }
        }
예제 #2
0
        public void New(string firstName,string lastName)
        {
            using (var ctx = new AccContexts())
            {
                base.New((int)enums.entityType.Person);

                var checkDuplication = ctx.person.Where(x => x.firstName == firstName && x.lastName == lastName).FirstOrDefault();
                if (checkDuplication != null)
                    throw new Exception("Person Duplicated");

                var newPerson = new AccountingLib.Models.person()
                {
                    firstName=firstName,
                    lastName=lastName,
                    entityID = base.ENTITYID
                };
                ctx.person.AddObject(newPerson);
                ctx.SaveChanges();

                this.id = newPerson.ID;
                this.firstname = newPerson.firstName;
                this.lastname = newPerson.lastName;
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the person EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToperson(person person)
 {
     base.AddObject("person", person);
 }
 /// <summary>
 /// Create a new person object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static person Createperson(global::System.Int32 id)
 {
     person person = new person();
     person.ID = id;
     return person;
 }