예제 #1
0
 public ActionResult Edit(Owner owner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(owner).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(owner);
 }
예제 #2
0
        public ActionResult Create(Owner owner)
        {
            if (ModelState.IsValid)
            {
                db.Owners.Add(owner);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(owner);
        }
예제 #3
0
 public void updateOwnerDbTest()
 {
     OwnerDAL target = new OwnerDAL();
     bool expected = true;
     bool actual;
     Owner check =new Owner();
     check.firstname = "Alexander";
     check.surname = "Carson";
     check.address1 = "92 Margarenstrasse";
     check.address2 = "Vienna";
     check.country = "Italy";
     check.email = "*****@*****.**";
     check.contactno = "+353 67639287828";
     check.holidayhomeno = "9876";
     actual = target.updateOwnerDb(check);
     Assert.AreEqual(expected, actual);
 }
예제 #4
0
 public ActionResult Create(Owner Owner)
 {
     try
     {
         if (ModelState.IsValid)
         {
             OwnerRepository.InsertOwner(Owner);
             OwnerRepository.Save();
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException)
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(Owner);
 }
예제 #5
0
파일: OwnerDAL.cs 프로젝트: DERESICL/Code
        public bool addOwnerDb(Owner own)
        {
            Owner owr = new Owner();
            try
            {
                owr = db.Owners.Add(own);
            }

            catch (Exception exp)
            {

                Exception j = exp;
                return false;

            }

            if (owr is Owner)
            {
                db.SaveChanges();
                return true;
            }
            return false;
        }
예제 #6
0
        public void parseOwnersTest()
        {
            StreamReader reader = new StreamReader("d:\\nci\\owners.csv");
            CSVParser target = new CSVParser();
            target.setStreamSource(reader);

            Owner owns = new Owner();
            owns.firstname="Alexander";
            owns.surname="Carson";
            owns.address1="92 Margarenstrasse";
            owns.address2="Vienna";
            owns.country = "Italy";
            owns.email="*****@*****.**";
            owns.contactno="+353 67639287828";
            owns.holidayhomeno="9876";

            List<Owner> expected = new List<Owner>();
            expected.Add(owns);
            List<Owner> actual;
            actual = target.parseOwners();

            Assert.AreEqual(expected[0].address1, actual[0].address1);
            Assert.AreEqual(expected[0].country, actual[0].country);
            Assert.AreEqual(expected[0].contactno, actual[0].contactno);
        }
예제 #7
0
파일: OwnerDAL.cs 프로젝트: DERESICL/Code
 public bool updateOwnerDb(Owner own)
 {
     db.Entry(own).State = EntityState.Modified;
     db.SaveChanges();
     return true;
 }
예제 #8
0
 public void UpdateOwner(Owner Owner)
 {
     context.Entry(Owner).State = EntityState.Modified;
 }
예제 #9
0
 public void InsertOwner(Owner Owner)
 {
     context.Owners.Add(Owner);
 }
예제 #10
0
파일: CSVParser.cs 프로젝트: DERESICL/Code
        //Create List to store your CSV data
        public List<Models.Owner> parseOwners()
        {
            CsvReader csv = new CsvReader(reader, true);
            int fieldCount = csv.FieldCount;
            List<Owner> ownerlist = new List<Owner>();

            String[] headers = csv.GetFieldHeaders();

            while (csv.ReadNextRecord())
            {
                Owner exObj = new Owner();

                for (int i = 0; i < fieldCount; i++)
                {
                    if (headers[i].Equals("firstname")) { exObj.firstname = csv[i]; }
                    else if (headers[i].Equals("surname")) { exObj.surname = csv[i]; }
                    else if (headers[i].Equals("address1")) { exObj.address1 = csv[i]; }
                    else if (headers[i].Equals("address2")) { exObj.address2 = csv[i]; }
                    else if (headers[i].Equals("country")) { exObj.country = csv[i]; }
                    else if (headers[i].Equals("email")) { exObj.email = csv[i]; }
                    else if (headers[i].Equals("contactno")) { exObj.contactno = csv[i]; }
                    else if (headers[i].Equals("holidayhomeno")) { exObj.holidayhomeno = csv[i]; }
                 }

                ownerlist.Add(exObj);
            }

            return ownerlist;
        }