Ejemplo n.º 1
0
        public long InsertOrUpdate(AddressModel model)
        {
            var address = new Address();

            if (model.Id > 0)
            {
                address = db.Addresses.SingleOrDefault(x => x.Id_Address == model.Id);

                model.ToDatabaseModel(address);
            }
            else
            {
                model.ToDatabaseModel(address);
                db.Addresses.Add(address);
            }

            db.SaveChanges();

            return(address.Id_Address);
        }