Esempio n. 1
0
        public void DeleteById(int id)            // Delete function
        {
            Subsidary emp = GetById(id);

            dbconn.Subsidaries.Remove(emp);
            dbconn.SaveChanges();
        }
Esempio n. 2
0
        public static SubsModel Translate(Subsidary sub)
        {
            var subModel = new SubsModel();

            subModel.Name = sub.Name;
            subModel.ID   = sub.ID;
            return(subModel);
        }
Esempio n. 3
0
        public Subsidary Add(Subsidary emp)       // Adding Function
        {
            Subsidary addedEmp = dbconn.Subsidaries.Add(emp);

            dbconn.SaveChanges();

            return(addedEmp);
        }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "ID,Name")] Subsidary subsidary)
 {
     if (ModelState.IsValid)
     {
         subsidariesBusinessManager.Update(subsidary);
     }
     return(View(subsidary));
 }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "ID,Name")] Subsidary subsidary)
        {
            if (ModelState.IsValid)
            {
                subsidariesBusinessManager.Add(subsidary);
                return(RedirectToAction("Index"));
            }

            return(View(subsidary));
        }
Esempio n. 6
0
        // add subs
        public ActionResult AddSubs(int subId, string subname)
        {
            var sub = new Subsidary();

            sub.Name = subname;
            sub.ID   = subId;
            if (searchSubs.Where(n => n.ID == subId).FirstOrDefault() == null)
            {
                searchSubs.Add(sub); // adding
            }

            return(PartialView("_SubsFilter", searchSubs));
        }
Esempio n. 7
0
        // GET: Subsidaries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Subsidary subsidary = subsidariesBusinessManager.GetById(id.Value);

            if (subsidary == null)
            {
                return(HttpNotFound());
            }
            return(View(subsidary));
        }
Esempio n. 8
0
        // Adding a new Subsidary not in the database
        public ActionResult AddNewSubsidary(int empId, string subname)
        {
            var       empSub       = new EmpSubsidary();
            Subsidary NewSubsidary = new Subsidary();

            NewSubsidary.Name = subname;
            var added = subsidiariesbusinessManager.Add(NewSubsidary);

            empSub.EmpID = empId;
            List <Subsidary> sub = subsidiariesbusinessManager.GetUnmappedSubsidiariesByEmpID(empId);

            if (sub.Where(j => j.ID == added.ID).FirstOrDefault() != null)
            {
                empSub.SubsidaryID = added.ID;
                empSubsBusinessManager.Add(empSub);
            }
            var empSubs = empSubsBusinessManager.GetByEmployeeID(empId);

            return(PartialView("_UserSubs", empSubs));
        }
Esempio n. 9
0
 public Subsidary Update(Subsidary emp)    // Update Function
 {
     dbconn.Entry(emp).State = EntityState.Modified;
     dbconn.SaveChanges();
     return(emp);
 }
Esempio n. 10
0
        public Subsidary GetById(int id)          // Get the ID Function
        {
            Subsidary emp = dbconn.Subsidaries.Where(e => e.ID == id).FirstOrDefault();

            return(emp);
        }
Esempio n. 11
0
 public Subsidary Update(Subsidary sub)
 {
     return(subsidariesDataManager.Update(sub));
 }
Esempio n. 12
0
 public Subsidary Add(Subsidary sub)
 {
     return(subsidariesDataManager.Add(sub));
 }