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

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

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

            dbconn.SaveChanges();

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

            return(View(subsidary));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 9
0
 public Subsidary Update(Subsidary emp)    // Update Function
 {
     dbconn.Entry(emp).State = EntityState.Modified;
     dbconn.SaveChanges();
     return(emp);
 }
Ejemplo n.º 10
0
        public Subsidary GetById(int id)          // Get the ID Function
        {
            Subsidary emp = dbconn.Subsidaries.Where(e => e.ID == id).FirstOrDefault();

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