Exemplo n.º 1
0
        public ActionResult Add(detail post)
        {
            if (ModelState.IsValid)
            {
                using (SLKDatabaseEntities db = new SLKDatabaseEntities())
                {
                    db.details.Add(new detail
                    {
                        FirstName    = post.FirstName,
                        MiddleName   = post.MiddleName,
                        LastName     = post.LastName,
                        PhoneNumber  = post.PhoneNumber,
                        Gender       = post.Gender,
                        DateOfBirth  = post.DateOfBirth,
                        EmailID      = post.EmailID,
                        Address      = post.Address,
                        City         = post.City,
                        ZipCode      = post.ZipCode,
                        State        = post.State,
                        Country      = post.Country,
                        Department   = post.Department,
                        TenthBoard   = post.TenthBoard,
                        TenthMarks   = post.TenthMarks,
                        TwelfthBoard = post.TwelfthBoard,
                        TwelfthMarks = post.TwelfthMarks,
                    });
                    db.SaveChanges();
                }

                ModelState.Clear();
            }
            return(View());
        }
Exemplo n.º 2
0
        //update
        //[HttpPut]
        public IHttpActionResult PutAnEmployee(DataViewModel s)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid data"));
            }

            using (var ctx = new SLKDatabaseEntities())
            {
                var existingStudent = ctx.registrations.Where(m => m.SlNo == s.SlNo).FirstOrDefault <registration>();

                if (existingStudent != null)
                {
                    existingStudent.UserName        = s.UserName;
                    existingStudent.EmailId         = s.EmailId;
                    existingStudent.Password        = s.Password;
                    existingStudent.ConfirmPassword = s.ConfirmPassword;
                    ctx.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            return(Ok());
        }
Exemplo n.º 3
0
        public ActionResult Edit(int UserId)
        {
            detail Post = new detail();

            using (SLKDatabaseEntities db = new SLKDatabaseEntities())
            {
                Post = db.details.Where(r => r.UserId == UserId).FirstOrDefault();
            }
            return(View(Post));
        }
Exemplo n.º 4
0
        public ActionResult Delete(detail Post)
        {
            if (ModelState.IsValid)
            {
                using (SLKDatabaseEntities db = new SLKDatabaseEntities())
                {
                    db.Entry(Post).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();
                    return(RedirectToAction("Home", "Home"));
                }
            }

            return(View(Post));
        }
Exemplo n.º 5
0
        public IHttpActionResult GetAllStudents(bool includeDetail = false)
        {
            IList <DataViewModel> students = null;

            using (var ctx = new SLKDatabaseEntities())
            {
                students = ctx.registrations
                           .Select(s => new DataViewModel()
                {
                    SlNo            = s.SlNo,
                    UserName        = s.UserName,
                    EmailId         = s.EmailId,
                    Password        = s.Password,
                    ConfirmPassword = s.ConfirmPassword,
                    //Detail = s.details == null || includeDetail == false ? null : new DetailViewModel()
                    //{
                    //    UserId = s.details.UserId,
                    //    FirstName = s.details.FirstName,
                    //    MiddleName = s.details.MiddleName,
                    //    LastName = s.details.LastName,
                    //    PhoneNumber = s.details.PhoneNumber,
                    //    Gender = s.details.Gender,
                    //    DateOfBirth = s.details.DateOfBirth,
                    //    EmailID = s.details.EmailID,
                    //    Address = s.details.Address,
                    //    City = s.details.City,
                    //    ZipCode = s.details.ZipCode,
                    //    State = s.details.State,
                    //    Country = s.details.Country,
                    //    Department = s.details.Department,
                    //    TenthBoard = s.details.TenthBoard,
                    //    TenthMarks = s.details.TenthMarks,
                    //    TwelfthBoard = s.details.TwelfthBoard,
                    //    TwelfthMarks = s.details.TwelfthMarks,
                    //}
                }).ToList <DataViewModel>();
            }

            if (students.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(students));
        }
Exemplo n.º 6
0
        public IHttpActionResult DeleteEmployee(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid student id"));
            }

            using (var ctx = new SLKDatabaseEntities())
            {
                var student = ctx.registrations
                              .Where(s => s.SlNo == id)
                              .FirstOrDefault();

                ctx.Entry(student).State = System.Data.Entity.EntityState.Deleted;
                ctx.SaveChanges();
            }

            return(Ok());
        }
Exemplo n.º 7
0
        public IHttpActionResult PostNewEmployee(DataViewModel s)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            using (var ctx = new SLKDatabaseEntities())
            {
                ctx.registrations.Add(new registration()
                {
                    UserName        = s.UserName,
                    EmailId         = s.EmailId,
                    Password        = s.Password,
                    ConfirmPassword = s.ConfirmPassword
                });

                ctx.SaveChanges();
            }

            return(Ok());
        }
Exemplo n.º 8
0
        //[AcceptVerbs("POST")]
        public IHttpActionResult Post1(DataViewModel student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            using (var ctx = new SLKDatabaseEntities())
            {
                ctx.registrations.Add(new registration()
                {
                    SlNo            = student.SlNo,
                    UserName        = student.UserName,
                    EmailId         = student.EmailId,
                    Password        = student.Password,
                    ConfirmPassword = student.ConfirmPassword,
                });

                ctx.SaveChanges();
            }

            return(Ok());
        }
Exemplo n.º 9
0
        public ActionResult Home()
        {
            detail model = new detail();

            using (SLKDatabaseEntities db = new SLKDatabaseEntities())
            {
                var data = db.details.ToList();

                List <detail> jobpos = new List <detail>();
                foreach (var item in data)
                {
                    detail obj = new detail();
                    obj.UserId       = item.UserId;
                    obj.FirstName    = item.FirstName;
                    obj.MiddleName   = item.MiddleName;
                    obj.LastName     = item.LastName;
                    obj.PhoneNumber  = item.PhoneNumber;
                    obj.Gender       = item.Gender;
                    obj.DateOfBirth  = item.DateOfBirth;
                    obj.EmailID      = item.EmailID;
                    obj.Address      = item.Address;
                    obj.City         = item.City;
                    obj.ZipCode      = item.ZipCode;
                    obj.State        = item.State;
                    obj.Country      = item.Country;
                    obj.Department   = item.Department;
                    obj.TenthBoard   = item.TenthBoard;
                    obj.TenthMarks   = item.TenthMarks;
                    obj.TwelfthBoard = item.TwelfthBoard;
                    obj.TwelfthMarks = item.TwelfthMarks;
                    jobpos.Add(obj);
                }
                ViewBag.list = jobpos;
            }
            return(View());
        }
Exemplo n.º 10
0
        public IHttpActionResult GetAllEmployees()
        {
            IList <DataViewModel> students = null;

            using (var ctx = new SLKDatabaseEntities())
            {
                students = ctx.registrations
                           .Select(s => new DataViewModel()
                {
                    SlNo            = s.SlNo,
                    UserName        = s.UserName,
                    EmailId         = s.EmailId,
                    Password        = s.Password,
                    ConfirmPassword = s.ConfirmPassword
                }).ToList <DataViewModel>();
            }

            if (students.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(students));
        }