public ActionResult Create([Bind(Include = "tblUserId,UserName,Password,RoleId")] tblUser tblUser)
        {
            var role = db.Roles.FirstOrDefault(x => x.RoleId == tblUser.RoleId);


            if (role.RoleName == "admin")
            {
                ViewBag.msg    = "You cant registration as admin, Please chose another option.";
                ViewBag.RoleId = new SelectList(db.Roles, "RoleId", "RoleName", tblUser.RoleId);
                return(View(tblUser));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    db.tblUsers.Add(tblUser);
                    db.SaveChanges();
                    return(RedirectToAction("Login", "Account"));
                }
            }


            ViewBag.RoleId = new SelectList(db.Roles, "RoleId", "RoleName", tblUser.RoleId);
            return(View(tblUser));
        }
        public ActionResult Create([Bind(Include = "RoleId,RoleName")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Name,FatherName,Address,Mobile,Email")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "BookedEventId,EventTypeId,CustomerId,StartTime,EndTime,EntryDate")] ScheduleEvent scheduleEvent)
        {
            if (ModelState.IsValid)
            {
                ScheduleEvent scheduleEvent1 = new ScheduleEvent {
                    EventTypeId = scheduleEvent.EventTypeId, CustomerId = scheduleEvent.CustomerId, StartTime = scheduleEvent.StartTime, EndTime = scheduleEvent.EndTime, EntryDate = DateTime.Now
                };
                db.ScheduleEvents.Add(scheduleEvent1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerId  = new SelectList(db.Customers, "Id", "Name", scheduleEvent.CustomerId);
            ViewBag.EventTypeId = new SelectList(db.Event_Types, "EventTypeId", "EventType", scheduleEvent.EventTypeId);
            return(View(scheduleEvent));
        }
Exemplo n.º 5
0
        public ActionResult Create(VM.Event_Type eVm)
        {
            if (ModelState.IsValid)
            {
                if (eVm.EventTypeImage != null)
                {
                    string newfilename  = Guid.NewGuid().ToString() + Path.GetExtension(eVm.EventTypeImage.FileName);
                    string newpath      = Path.Combine("Images", "EvType", newfilename);
                    string filetoFolder = Path.Combine(Server.MapPath("~/" + newpath));
                    eVm.EventTypeImage.SaveAs(filetoFolder);
                    Event_Type event_Type = new Event_Type {
                        EventType = eVm.EventType, EventTypeImage = newpath
                    };
                    db.Event_Types.Add(event_Type);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(eVm));
        }