public ActionResult Create([Bind(Include = "Id,lon,lat,Name,ReviewGrade,NumberGrades")] BeautySalons beautySalon)
        {
            if (ModelState.IsValid)
            {
                db.BeautySalons.Add(beautySalon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(beautySalon));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,lon,lat,Name,ReviewGrade,NumberGrades")] ClothingShops clothingShop)
        {
            if (ModelState.IsValid)
            {
                db.ClothingShops.Add(clothingShop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clothingShop));
        }
        public ActionResult Create([Bind(Include = "Booking_ID,Total_Fare,FK_Train_Detail_ID")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                db.Bookings.Add(booking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FK_Train_Detail_ID = new SelectList(db.Train_Detail, "Train_Detail_ID", "Source", booking.FK_Train_Detail_ID);
            return(View(booking));
        }
        public ActionResult Create([Bind(Include = "PB_ID,FK_Booking_ID,FK_ID")] Passenger_Booking passenger_Booking)
        {
            if (ModelState.IsValid)
            {
                db.Passenger_Booking.Add(passenger_Booking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FK_Booking_ID = new SelectList(db.Bookings, "Booking_ID", "Booking_ID", passenger_Booking.FK_Booking_ID);
            ViewBag.FK_ID         = new SelectList(db.Passenger_Details, "ID", "FName", passenger_Booking.FK_ID);
            return(View(passenger_Booking));
        }
 public ActionResult Create([Bind(Include = "Id,Name")] Image image, HttpPostedFileBase postedFile)
 {
     ModelState.Clear(); var myUniqueFileName = string.Format(@"{0}", Guid.NewGuid()); image.Path = myUniqueFileName; TryValidateModel(image);
     if (ModelState.IsValid)
     {
         string serverPath    = Server.MapPath("~/Uploads/");
         string fileExtension = Path.GetExtension(postedFile.FileName);
         string filePath      = image.Path + fileExtension; image.Path = filePath;
         postedFile.SaveAs(serverPath + image.Path);
         db.Images.Add(image); db.SaveChanges(); return(RedirectToAction("Index"));
     }
     return(View(image));
 }
 public void SaveProgramTypes(List <ProgramTypeDto> programTypes)
 {
     using (var context = new Model2())
     {
         using (var tran = context.Database.BeginTransaction())
         {
             try
             {
                 foreach (ProgramTypeDto programTypeDTO in programTypes)
                 {
                     Program_type program_Type = context
                                                 .Program_type
                                                 .Where(x => x.name.Equals(programTypeDTO.name))
                                                 .FirstOrDefault();
                     if (program_Type == null)
                     {
                         program_Type = Mapper.Map <ProgramTypeDto, Program_type>(programTypeDTO);
                         context.Program_type.Add(program_Type);
                     }
                 }
                 context.SaveChanges();
                 tran.Commit();
             }
             catch (Exception ex)
             {
                 tran.Rollback();
                 throw ex;
             }
         }
     }
 }
예제 #7
0
        // GET: Event/Edit/5
        public ActionResult Edit(_event item)
        {
            {
                var u = ctx._event.Where(x => x.id_Ev == item.id_Ev).FirstOrDefault();

                if (ModelState.IsValid)
                {
                    u.title       = item.title;
                    u.description = item.description;
                    u.capacity    = item.capacity;
                    u.cat         = item.cat;
                    u.startDate   = item.startDate;
                    u.endDate     = item.endDate;
                    u.startDate   = localDate;



                    ctx.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(u));
                }
            }
        }
 public void SavePrograms(List <ProgramTvDto> programs)
 {
     using (var context = new Model2())
     {
         using (var tran = context.Database.BeginTransaction())
         {
             try
             {
                 foreach (ProgramTvDto programDto in programs)
                 {
                     Program_tv   program_tv   = Mapper.Map <ProgramTvDto, Program_tv>(programDto);
                     Program_type program_Type = context
                                                 .Program_type
                                                 .Where(x => x.name.Equals(programDto.type_name))
                                                 .FirstOrDefault();
                     program_tv.Program_type = program_Type;
                     context.Program_tv.Add(program_tv);
                 }
                 context.SaveChanges();
                 tran.Commit();
             }
             catch (Exception ex)
             {
                 tran.Rollback();
                 throw ex;
             }
         }
     }
 }
예제 #9
0
 public static void InsertMember(Member c)
 {
     using (Model2 m = new Model2())
     {
         m.Members.Add(c);
         m.SaveChanges();
     }
 }
예제 #10
0
 public static void UpdateMember(Member c)
 {
     using (Model2 m = new Model2())
     {
         m.Entry(c).State = System.Data.Entity.EntityState.Modified;
         m.SaveChanges();
     }
 }
예제 #11
0
 public static void DeleteMember(Member c)
 {
     using (Model2 m = new Model2())
     {
         m.Members.Remove(c);
         m.SaveChanges();
     }
 }
예제 #12
0
 public static void InsertarOrdenes(ORDENES ordenes)
 {
     using (var model2 = new Model2())
     {
         model2.ORDENES.Add(ordenes);
         model2.SaveChanges();
     }
 }
예제 #13
0
 public static void InsertarClientes(CLIENTES cliente)
 {
     using (var model2 = new Model2())
     {
         model2.CLIENTES.Add(cliente);
         model2.SaveChanges();
     }
 }
예제 #14
0
파일: PostDao.cs 프로젝트: kien199/NewK
        public int AddPost(string tieude, string slug, string tomtat, string noidung, string thumbnail, int theloat_id)
        {
            try
            {
                baiviet newPost = new baiviet();
                newPost.tieude  = tieude;
                newPost.slug    = slug;
                newPost.tomtat  = tomtat;
                newPost.noidung = noidung;
                if (thumbnail == "http://localhost:44333/Asset_Admin/images/")
                {
                    newPost.thumbnail = "http://localhost:44333/Asset_Admin/images/default-new-image.png";
                }
                else
                {
                    newPost.thumbnail = thumbnail;
                }
                newPost.soluotxem   = 0;
                newPost.noibat      = false;
                newPost.ngaytao     = DateTime.Now;
                newPost.ngaycapnhat = DateTime.Now;
                newPost.hide        = true;
                newPost.theloai_id  = theloat_id;
                db.baiviets.Add(newPost);
                db.SaveChanges();

                return(newPost.id);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
 public ActionResult Edit([Bind(Include = "Id,lon,lat,Name,ReviewGrade,NumberGrades")] Hairdresser hairdresser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hairdresser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hairdresser));
 }
예제 #16
0
        public ActionResult Create([Bind(Include = "TicketDay,AvailableSeatCount")] TicketDetail ticketDetail)
        {
            if (ModelState.IsValid)
            {
                db.TicketDetails.Add(ticketDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ticketDetail));
        }
예제 #17
0
파일: CommentDao.cs 프로젝트: kien199/NewK
        public binhluan AddComment(string noidung, string tennguoidang, int baivietId)
        {
            try
            {
                binhluan newCmt = new binhluan();
                newCmt.noidung      = noidung;
                newCmt.tennguoidang = tennguoidang;
                newCmt.baiviet_id   = baivietId;
                newCmt.ngaytao      = DateTime.Now;
                newCmt.ngaycapnhat  = DateTime.Now;
                db.binhluans.Add(newCmt);
                db.SaveChanges();

                return(newCmt);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #18
0
        public int AddUser(string name, string email, string password)
        {
            var test = db.nguoidungs.Where(x => x.email == email).SingleOrDefault();

            if (test == null)
            {
                nguoidung user = new nguoidung();
                user.ten         = name;
                user.email       = email;
                user.matkhau     = password;
                user.ngaytao     = DateTime.Now;
                user.ngaycapnhat = DateTime.Now;
                user.vaitro      = 1; //Admin
                db.nguoidungs.Add(user);
                db.SaveChanges();
                return(user.id);
            }
            else
            {
                return(-1);
            }
        }
예제 #19
0
 public static void ModificarPizza(PIZZAS pizza)
 {
     using (var model2 = new Model2())
     {
         // modificacion
         PIZZAS pizzaAntigua = model2.PIZZAS
                               .Where(p => p.IDPIZZA == pizza.IDPIZZA).FirstOrDefault();
         pizzaAntigua.PRECIO = pizza.PRECIO;
         pizzaAntigua.IMAGEN = pizza.IMAGEN;
         pizzaAntigua.TITULO = pizza.TITULO;
         model2.SaveChanges();
     }
 }
예제 #20
0
 public void DeleteProgramsWithIncorrectEndDate()
 {
     using (var context = new Model2())
     {
         var programsToDelete = context
                                .Program_tv
                                .Where(x => ((DateTime)x.end_date).Year == 2100)
                                .ToList();
         programsToDelete
         .ForEach(x => context.Program_tv.Remove(x));
         context.SaveChanges();
     }
 }
예제 #21
0
        public ActionResult Create([Bind(Include = "Payment_ID,Status,FK_Booking_ID")] Payment payment)
        {
            if (ModelState.IsValid)
            {
                db.Payments.Add(payment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FK_Booking_ID = new SelectList(db.Bookings, "Booking_ID", "Booking_ID", payment.FK_Booking_ID);
            return(View(payment));
        }
예제 #22
0
        private void buttondeleteacc_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection r = dataGridView1.SelectedRows;
            Model2 db = new Model2();

            foreach (MatHang i in db.MatHangs)
            {
                foreach (DataGridViewRow j in r)
                {
                    if (i.MaHang == j.Cells["MaHang"].Value.ToString())
                    {
                        db.MatHangs.Remove(i);
                    }
                }
            }
            db.SaveChanges();
            Show();
        }
예제 #23
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var user          = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text
            };
            IdentityResult result = manager.Create(user, Password.Text);
            Member         m      = new Member();

            {
                m.MemberName = Name.Text;
                m.PhoneNo    = Phone.Text;
                m.Email      = Email.Text;
                m.Password   = Password.Text;
            };

            Model2 a = new Model2();

            a.Members.Add(m);
            a.SaveChanges();
            if (result.Succeeded)
            {
                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                //string code = manager.GenerateEmailConfirmationToken(user.Id);
                //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                Session["user"] = "******";
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }

            //Session["name"] = m.MemberName;
            //Response.Redirect("~/Default.aspx");
        }
 public ActionResult KayitOl(string CUSTOMERNAME, string EMAIL, string PASSWORD, string pswrepeat, int AGE, string GENDER)
 {
     if (PASSWORD == pswrepeat)
     {
         var x = new CUSTOMERS();
         x.CUSTOMERNAME = CUSTOMERNAME;
         x.AGE          = AGE;
         x.GENDER       = GENDER;
         x.EMAIL        = EMAIL;
         x.PASSWORD     = PASSWORD;
         db.CUSTOMERS.Add(x);
         db.SaveChanges();
         ViewBag.Basarili = "Üyeliğiniz tamamlanmıştır.";
         return(RedirectToAction("Index", "Admin"));
     }
     else
     {
         ViewBag.Basarili = "Üyeliğiniz tamamlanamamıştır.";
         return(View());
     }
 }
예제 #25
0
        public XrefB CreateABCPair(string someName, string detail, string address, int zip)
        {
            var a = context.EntityAs.Add(new EntityA {
                SomeName = someName, Detail = detail
            });
            var c = context.EntityCs.Add(new EntityC {
                Address = address, Zipcode = zip
            });

            context.SaveChanges();
            var b = context.XrefBs.Add(new XrefB {
                EntityAId = a.EntityAId, EntityCId = c.EntityCId
            });

            context.SaveChanges();
            return(b);
        }
예제 #26
0
 public long Insert(MenuType entity)
 {
     db.MenuType.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
예제 #27
0
 public long Insert(tAdmin user)
 {
     db.tAdmins.Add(user);
     db.SaveChanges();
     return(user.ID);
 }
예제 #28
0
 public long Insert(About entity)
 {
     db.About.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
예제 #29
0
 public void Commit()
 {
     dataContext.SaveChanges();
 }
예제 #30
0
 public long Insert(Content entity)
 {
     db.Content.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }