public JsonResult updateuserlist(user_list veri)
        {
            try
            {
                int?      duzenleyen = Convert.ToInt32(Session["userID"].ToString());
                user_list duzenlenen = (from a in ent.user_list where a.user_list_id == veri.user_list_id && a.user_id == duzenleyen select a).FirstOrDefault();
                if (veri.score > 10)
                {
                    duzenlenen.score = 10;
                }
                else if (veri.score < 0)
                {
                    duzenlenen.score = 0;
                }
                duzenlenen.score          = veri.score;
                duzenlenen.list_status_id = veri.list_status_id;
                if (duzenlenen.list_status_id == 2 || duzenlenen.list_status_id == 7 || duzenlenen.list_status_id == 12 || duzenlenen.list_status_id == 15)
                {
                    if (duzenlenen.list.episode != null)
                    {
                        duzenlenen.episode_complete = (int)duzenlenen.list.episode;
                    }
                }
                duzenlenen.episode_complete = veri.episode_complete;
                duzenlenen.user_tags        = veri.user_tags;
                //duzenlenen.list_status_id = veri.list_status_id;
                //duzenlenen = veri;
                ent.SaveChanges();



                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); }
        }
Esempio n. 2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // to save user object to user_list when user is register
                    user_list u = new user_list {
                        user_email = model.Email, username = model.Email
                    };
                    ApplicationDbContext db = new ApplicationDbContext();
                    db.user_list.Add(u);
                    db.SaveChanges();

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public JsonResult deleteuserlist(user_list veri)
        {
            try
            {
                user_list silincek = (from a in ent.user_list where a.user_list_id == veri.user_list_id select a).FirstOrDefault();
                ent.user_list.Remove(silincek);

                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); }
        }
 public JsonResult createuserlist(user_list veri)
 {
     try
     {
         ent.user_list.Add(veri);
         ent.SaveChanges();
         return(Json(new { Result = "OK", Record = veri }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Esempio n. 5
0
 public ActionResult GrocerySave(grocery_list model)
 {
     if (model != null)
     {
         db.grocery_list.Add(model);
         string    tmp_name = User.Identity.GetUserName();
         user_list user     = db.user_list.Where(x => x.user_email == tmp_name).FirstOrDefault();
         model.userid = user.userid;
         db.SaveChanges();
         return(Json(model.grocery_id));
     }
     return(Json("An Error Has occoured"));
 }
Esempio n. 6
0
        public JsonResult addtomylist(int?listid, int?statusid, int?score, int?epseen)
        {
            try
            {
                int?userid = Convert.ToInt32(Session["userID"].ToString());

                var control = (from a in ent.user_list where a.user_id == userid && a.list_id == listid select a).FirstOrDefault();

                if (control != null)
                {
                    return(Json(new { Result = "ERROR", Message = "Already added." }));
                }


                if (score < 0)
                {
                    score = 0;
                }
                else if (score > 10)
                {
                    score = 10;
                }

                user_list userlst = new user_list();
                userlst.user_id        = (int)userid;
                userlst.list_id        = (int)listid;
                userlst.list_status_id = (int)statusid;
                userlst.score          = score;
                if (epseen == null)
                {
                    userlst.episode_complete = 0;
                }
                else
                {
                    userlst.episode_complete = (int)epseen;
                }
                userlst.addeddate = DateTime.Now;
                ent.user_list.Add(userlst);
                ent.SaveChanges();


                return(Json(new { Result = "OK", Message = "Recorded" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = "Something happened bad. Tell it to us, for now ([email protected]) Error Detail : " + ex.Message }));
            }
        }
Esempio n. 7
0
        public ActionResult UserProfile(user_list user, string submit)
        {
            var UserSession = Session["username"];

            if (submit == "Save new password") // If the submit-button for saving password is pressed
            {
                if (ModelState.IsValid)
                {
                    using (var context = new CanteenDBContext())
                    {
                        var userEdit = context.Users.Where(x => x.username == UserSession).FirstOrDefault <user_list>();

                        if (user.oldPassword == userEdit.password)
                        {
                            if (userEdit != null)
                            {
                                userEdit.password = user.newPassword;
                                context.SaveChanges();

                                string test3 = "password changed to" + user.newPassword;
                                return(View(userEdit));
                            }
                        }
                        string test = "old password incorrect";
                        return(Content(test));
                    }
                }
                return(Content(test2));
            }

            if (submit == "Save new email")
            {
                if (ModelState.IsValid)
                {
                    using (var context = new CanteenDBContext())
                    {
                        var userEdit = context.Users.Where(x => x.username == UserSession).FirstOrDefault <user_list>();

                        if (user.oldPassword == userEdit.password)
                        {
                            if (userEdit != null)
                            {
                                userEdit.email = user.email;
                                context.SaveChanges();

                                string test3 = "email changed to" + user.email;
                                return(View(userEdit));
                            }
                        }
                        string test = "old password incorrect";
                        return(Content(test));
                    }
                }
            }

            if (submit == "Save new number")
            {
                if (ModelState.IsValid)
                {
                    using (var context = new CanteenDBContext())
                    {
                        var userEdit = context.Users.Where(x => x.username == UserSession).FirstOrDefault <user_list>();

                        if (user.oldPassword == userEdit.password)
                        {
                            if (userEdit != null)
                            {
                                userEdit.phone = user.phone;
                                context.SaveChanges();

                                string test3 = "phone changed to" + user.phone;
                                return(View(userEdit));
                            }
                        }
                        string test = "old password incorrect";
                        return(Content(test));
                    }
                }
            }
            return(Content(submit));
        }
Esempio n. 8
0
        public ActionResult addList(string seriestitle, int listTypes, int?episode, string datepicker, string addlistcheck, int?liststatus)
        {
            if (Session["userID"] == null)
            {
                return(View("Index"));
            }
            try
            {
                DateTime tarih;
                bool     tarihceviri = DateTime.TryParse(datepicker, System.Globalization.CultureInfo.CurrentUICulture, System.Globalization.DateTimeStyles.None, out tarih);


                ViewBag.listTypes = (from a in ent.list_type select a).ToList().Select(b => new SelectListItem
                {
                    Value = b.list_type_id.ToString(),
                    Text  = b.type_name
                });

                ViewBag.liststatus = (from a in ent.user_list_status select a).ToList().Select(b => new SelectListItem
                {
                    Value = b.user_list_status_id.ToString(),
                    Text  = b.status_name
                });

                list liste = new list();
                liste.name         = seriestitle;
                liste.list_type_id = listTypes;
                liste.episode      = episode;
                if (tarihceviri)
                {
                    liste.release_date = tarih;
                }
                liste.aktif = false;
                ent.list.Add(liste);
                ent.SaveChanges();

                int userID     = Convert.ToInt32(Session["userID"].ToString());
                int lastlistid = (from a in ent.list orderby a.list_id descending select a.list_id).FirstOrDefault();
                if (addlistcheck == "on")
                {
                    user_list userlist = new user_list();
                    userlist.user_id        = userID;
                    userlist.list_id        = lastlistid;
                    userlist.list_status_id = (int)liststatus;
                    userlist.addeddate      = DateTime.Now;
                    ent.user_list.Add(userlist);
                    ent.SaveChanges();
                }

                logs log = new logs();
                log.log_type_id = 2;
                log.createdDate = DateTime.Now;
                log.info        = "user: "******" list: " + lastlistid;
                ent.logs.Add(log);
                ent.SaveChanges();


                ViewBag.sonuc = "Added.";
                return(View());
            }
            catch { ViewBag.sonuc = "Something wrong. Try again."; return(View()); }
        }