Example #1
0
        public async Task <ActionResult> Create([Bind("Id,Firstname,Lastname,Address," +
                                                      "Gender,CreatedDate,Email,PhoneNumber,Salary,HireDate")] Teacher model)
        {
            model.CreatedDate  = DateTime.UtcNow.Date;
            model.ModifiedDate = DateTime.UtcNow.Date;
            if (ModelState.IsValid)
            {
                var o = new Teacher();
                o.Address      = model.Address;
                o.CreatedDate  = model.CreatedDate;
                o.ModifiedDate = model.ModifiedDate;
                o.Lastname     = model.Lastname.ToUpper();
                o.Firstname    = model.Firstname.ToUpper();
                o.Gender       = model.Gender;
                o.Email        = model.Email;
                o.PhoneNumber  = model.PhoneNumber;
                o.HireDate     = model.HireDate;
                o.Salary       = model.Salary;
                th.Add(o);
                await th.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(PartialView(model));
        }