Esempio n. 1
0
        // GET: Employer/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            var employer = await EmployerLib.GetEmployer(id.ToString());

            if (employer == null)
            {
                var errorMsg = string.Format("Employer {0} not found.", id);
                throw new HttpException(404, errorMsg);
            }
            return(View(employer));
        }
Esempio n. 2
0
        public async Task <ActionResult> Delete(string id, FormCollection collection)
        {
            try
            {
                await EmployerLib.DeleteEmployer(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 3
0
        public async Task <ActionResult> Edit(string id, FormCollection collection)
        {
            try
            {
                var employerName = collection["EmployerName"].ToString();
                var employer     = new Employer()
                {
                    Id           = id,
                    EmployerName = employerName
                };
                await EmployerLib.UpdateEmployer(employer);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Esempio n. 4
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                var rand         = new Random();
                var id           = rand.Next().ToString();
                var employerName = collection["EmployerName"].ToString();
                var employer     = new Employer()
                {
                    Id           = id,
                    EmployerName = employerName
                };
                await EmployerLib.InsertEmployer(employer);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Esempio n. 5
0
        // GET: Employer
        public async Task <ActionResult> Index()
        {
            var employers = await EmployerLib.GetAllEmployers();

            return(View(employers));
        }