Exemple #1
0
 public Person GetPerson(int personID)
 {
     using (PersonDAL pDAL = new PersonDAL())
     {
         return(pDAL.GetPerson(personID));
     }
 }
Exemple #2
0
        public DataSet ReadPerson()
        {
            DataSet   set   = new DataSet();
            PersonDAL dAL   = new PersonDAL();
            var       table = dAL.GetPerson();


            set.Tables.Add(table);
            return(set);
        }
Exemple #3
0
        public IActionResult EditPerson()
        {
            InitView();

            var id        = HttpContext.Session.GetString(personIdKey);
            var personDal = new PersonDAL(_configuration);
            var person    = personDal.GetPerson(id);

            return(View(person));
        }
Exemple #4
0
    public static void Main(string[] args)
    {
        //在更新数据前显示对象信息
        PersonDAL personDAL = new PersonDAL();
        var beforeObj = personDAL.GetPerson(24);
        personDAL.Display("Before", beforeObj);

        //更新Person的SecondName,Age两个属性
        Person person1 = new Person();
        person1.Id = 24;
        person1.FirstName = "Leslie";
        person1.SecondName = "Wang";
        person1.Age = 32;
        person1.Address = "Tianhe";
        person1.Telephone = "13660123456";
        person1.EMail = "*****@*****.**";

        //更新Person的FirstName属性
        Person person2 = new Person();
        person2.Id = 24;
        person2.FirstName = "Rose";
        person2.SecondName = "Lee";
        person2.Age = 34;
        person2.Address = "Tianhe";
        person2.Telephone = "13660123456";
        person2.EMail = "*****@*****.**";

        //使用异步方式同时更新数据
        MyDelegate myDelegate = new MyDelegate(personDAL.Update);
        myDelegate.BeginInvoke(person1, null, null);
        myDelegate.BeginInvoke(person2, null, null);

        Thread.Sleep(300);
        //在更新数据后显示对象信息
        var afterObj = personDAL.GetPerson(24);
        personDAL.Display("After", afterObj);
        Console.ReadKey();
    }
Exemple #5
0
        public Person GetPerson()
        {
            try
            {
                PersonDAL repository = new PersonDAL();
                Person    person     = new Person();

                return(person = repository.GetPerson());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        public IActionResult DeletePerson()
        {
            InitView();

            var         id     = HttpContext.Session.GetString(personIdKey);
            PersonModel person = null;

            try
            {
                var personDal = new PersonDAL(_configuration);
                person = personDal.GetPerson(id);
                personDal.DeletePerson(id);
                ViewBag.ErrorMessage = string.Empty;
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = "Error Deleting Person from Database";
            }

            return(View(person));
        }
        public IActionResult BuyProduct(string PID)
        {
            InitView();

            if (ViewBag.ShowLoginForm)
            {
                ViewBag.LoginMessage = "User not logged in.";
                return(View("Index"));
            }

            var productDal = new ProductDAL(_configuration);
            var product    = productDal.GetProduct(Convert.ToInt32(PID));

            productDal.UpdateInventory(product, 1);

            var personDal = new PersonDAL(_configuration);
            var person    = personDal.GetPerson(HttpContext.Session.GetString(personIdKey));

            var transactionDal = new TransactionDAL(_configuration);
            var txn            = new SaleTransactionModel()
            {
                PersonId        = person.PersonId,
                ProductId       = product.ProductId,
                TransactionTime = DateTime.Now,
                Quantity        = 1
            };

            var tranId = transactionDal.InsertTransaction(txn);

            var purchase = new PurchaseModel()
            {
                Person  = person,
                Product = product,
                SalesId = tranId
            };

            return(View(purchase));
        }
Exemple #8
0
        public ResultBM GetPerson(int personId)
        {
            try
            {
                AddressBLL addressBll    = new AddressBLL();
                ResultBM   resultAddress = null;
                PersonDAL  personDal     = new PersonDAL();
                PersonBM   personBm      = null;
                PersonDTO  personDto     = personDal.GetPerson(personId);

                // Si la persona existe, debería existir la dirección.
                if (personDto != null)
                {
                    resultAddress = addressBll.GetAddress(personDto.addressId);
                    if (!resultAddress.IsValid())
                    {
                        return(resultAddress);
                    }

                    if (resultAddress.GetValue() != null)
                    {
                        personBm = new PersonBM(personDto, resultAddress.GetValue <AddressBM>());
                    }
                    else
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " addressId " + personDto.addressId);
                    }
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", personBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }