Exemplo n.º 1
0
        // GET: Interships/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Intership intership = db.Interships.Include(t => t.IntershipFullDescription).FirstOrDefault(t => t.ID == id);

            if (intership == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Stations = db.DictStateInterships.ToList();
            var model = new Intership_MVC_Model
            {
                ID = intership.ID,
                IntershipFullDescription  = intership.IntershipFullDescription,
                DictStateIntership_ID     = intership.DictStateIntership.ID,
                IntershipShortDescription = intership.IntershipShortDescription,
                IntershipName             = intership.IntershipName,
                DateCreate       = intership.DateCreate,
                DateEdit         = intership.DateEdit,
                ID_Employer      = intership.ID_Employer,
                ImproverPosition = intership.ImproverPosition
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Intership intership = db.Interships.Find(id);

            db.Interships.Remove(intership);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // GET: Interships/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Intership intership = db.Interships.Include(t => t.DictStateIntership).FirstOrDefault(t => t.ID == id);

            if (intership == null)
            {
                return(HttpNotFound());
            }
            return(View(intership));
        }
Exemplo n.º 4
0
        // GET: Interships/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Intership intership = db.Interships.Find(id);

            if (intership == null)
            {
                return(HttpNotFound());
            }
            return(View(intership));
        }
Exemplo n.º 5
0
        public void loadData()
        {
            string fileSource = "../../..Baza Danych/Employers.txt";

            //Load employee data from file/database etc.
            using (StreamReader file = new StreamReader(fileSource))
            {
                int counter = 0;
                string ln;

                while ((ln = file.ReadLine()) != null)
                {
                    var data = ln.Split(',');

                    var firstName = data[0];
                    var lastName = data[1];
                    var contractType = data[2];
                    int monthlySalary = Int32.Parse(data[3]);
                    int overtime = Int32.Parse(data[4]);
                    var employee = new Employee(firstName, lastName);

                    Contract contract;
                    switch (contractType)
                    {
                        case "fullTime":
                            contract = new FullTime(monthlySalary, overtime);
                            employee.ChangeContract(contract);
                            break;
                        case "intership":
                            contract = new Intership(monthlySalary);
                            employee.ChangeContract(contract);
                            break;
                        default:
                            // Do nothing, throw error
                            break;
                    }

                    Employers.Add(employee);
                    Console.WriteLine(ln);
                    counter++;
                }
                file.Close();
                Console.WriteLine($"File has {counter} lines.");
            }
        }
Exemplo n.º 6
0
        public ActionResult Create(Intership_MVC_Model model)
        {
            if (ModelState.IsValid)
            {
                var intership = new Intership
                {
                    DictStateIntership        = db.DictStateInterships.FirstOrDefault(t => t.ID == model.ID),
                    DateCreate                = DateTime.Now,
                    DateEdit                  = DateTime.Now,
                    ID_Employer               = 1, //TODO исправить после привязки
                    ImproverPosition          = model.ImproverPosition,
                    IntershipFullDescription  = model.IntershipFullDescription,
                    IntershipName             = model.IntershipName,
                    IntershipShortDescription = model.IntershipShortDescription
                };
                db.Interships.Add(intership);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }