コード例 #1
0
 public ActionResult Registered(Registration registration)
 {
     using (RegistrationEntities db = new RegistrationEntities())
     {
         try
         {
             db.Registration.Add(registration);
             db.SaveChanges();
         } catch
         {
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.Name = registration.NameAndSurname;
     return(View());
 }
コード例 #2
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (RegistrationEntities dc = new RegistrationEntities())
            {
                var v = dc.Calendars.Where(a => a.EventID == eventID).FirstOrDefault();
                if (v != null)
                {
                    dc.Calendars.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
コード例 #3
0
        public ActionResult DeleteClientByEmail(string email)
        {
            email = email.ToLower().Trim();
            try
            {
                RegistrationEntities db = new RegistrationEntities();
                Client c = db.Clients.Find(email);
                db.Clients.Remove(c);
                db.SaveChanges();

                Messagebox("Client deletion Successfull");
                return(View());
            }
            catch (Exception e)
            {
                Messagebox("An error occured, client deletion failed");
                return(View("Index"));
            }
        }
        public ActionResult Registration([Bind(Exclude = "CreatedBy, CreatedDate")] User user)
        {
            bool   status  = false;
            string message = "";

            if (ModelState.IsValid)
            {
                #region
                var isExist = IsEmail(user.Email);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExists", "Email already exists");
                    return(View(user));
                }
                #endregion

                #region
                user.Password        = Hash.HashPass(user.Password);
                user.ConfirmPassword = Hash.HashPass(user.ConfirmPassword);
                #endregion

                user.CreatedBy   = "Admin";
                user.CreatedDate = Convert.ToString(DateTime.Now);

                #region Saving to databse
                using (RegistrationEntities rs = new RegistrationEntities())
                {
                    rs.Users.Add(user);
                    rs.SaveChanges();
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }
            ViewBag.Message = message;
            ViewBag.Status  = status;
            return(View(user));
        }
コード例 #5
0
        public ActionResult DeleteClientByFullName(string fullName)
        {
            fullName = fullName.Trim();
            try
            {
                RegistrationEntities ent     = new RegistrationEntities();
                List <Client>        clients = ent.Clients.Where(x => x.FullName.ToLower() == fullName.ToLower()).ToList();
                foreach (var i in clients)
                {
                    ent.Clients.Remove(i);
                }
                ent.SaveChanges();

                Messagebox("Client deletion Successfull");
                return(View());
            }
            catch (Exception e)
            {
                Messagebox("An error occured, client deletion failed");
                return(View("Index"));
            }
        }
コード例 #6
0
        public ActionResult Register([Bind(Include = "email,fullName,address,age,phone")] Client client)
        {
            using (RegistrationEntities entities = new RegistrationEntities())
            {
                try
                {
                    if (client.Email == "" || client.FullName == "" || client.Address == "")
                    {
                        Messagebox("Please ensure all required fields contain data");
                        return(View("RegForm"));
                    }

                    entities.Clients.Add(client);
                    entities.SaveChanges();
                    Messagebox("Client Successfully Registered");
                    return(View(client));
                }
                catch (Exception e)
                {
                    Messagebox("An error occurred, Please ensure all required fields contain data");
                    return(View("RegForm"));
                }
            }
        }
コード例 #7
0
 public IHttpActionResult insert(detail m)
 {
     dbobj.details.Add(m);
     dbobj.SaveChanges();
     return(Ok("Record succesfully save"));
 }