Пример #1
0
        public ActionResult SetDataInDataBase(tblUser model)
        {
            tblUser tbl = new tblUser();

            tbl.Name     = model.Name;
            tbl.Email    = model.Email;
            tbl.Password = model.Password;
            db.tblUsers.Add(tbl);
            db.SaveChanges();

            return(View());
        }
        public ActionResult Save(Register register)
        {
            try
            {
                #region update
                if (register.id != 0)
                {
                    Register update_Data = db.Registers.Where(s => s.id == register.id).FirstOrDefault();
                    update_Data.FirstName = register.FirstName.ToString();
                    update_Data.LastName  = register.LastName;
                    update_Data.Birthday  = register.Birthday;
                    update_Data.Address   = register.Address;
                    update_Data.Age       = CalAge(register.Birthday);
                }
                #endregion update

                #region insert
                else
                {
                    register.Age = CalAge(register.Birthday);
                    db.Registers.Add(register);
                }
                #endregion insert

                db.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            var allRegister = (from s in db.Registers select s).ToList();
            ViewBag.dataList = allRegister;
            return(PartialView("_AddMember"));
        }
Пример #3
0
        public ActionResult SaveReportInDB(string name)
        {
            byte[]     file;
            var        path       = HttpRuntime.AppDomainAppPath + @"resources\";
            string     files      = System.IO.Directory.GetFiles(path, name).FirstOrDefault();
            TestReport testReport = new TestReport();

            var stream = new FileStream(files, FileMode.Open, FileAccess.Read);

            using (var reader = new BinaryReader(stream))
            {
                file = reader.ReadBytes((int)stream.Length);
            }
            var abc = testEntities.TestReports.Where(x => x.ReportName == name).FirstOrDefault();

            if (abc == null)
            {
                testReport.ReportName = name;
                testReport.ReportData = file;
                testEntities.TestReports.Add(testReport);
                testEntities.SaveChanges();
            }
            else
            {
                abc.ReportData = file;

                testEntities.SaveChanges();
            }


            var dataSetsService = HttpContext.GetServiceFromContext <IDataSetsService>();

            var dataSetsList = dataSetsService.GetDataSetsList();

            return(Json(dataSetsList, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit([Bind(Include = "iD,firstName,lastName,feesPaid,gender,emailId,telephoneNumber,dateOfBirth,isActive,creationDate,lastModifiedDate")] sp_select_all_id_Result sp_select_all_id_Result)
 {
     if (ModelState.IsValid)
     {
         //db.Entry(sp_select_all_id_Result).State = EntityState.Modified;
         db.sp_contacto_upd(
             sp_select_all_id_Result.iD,
             sp_select_all_id_Result.firstName,
             sp_select_all_id_Result.lastName,
             sp_select_all_id_Result.feesPaid,
             sp_select_all_id_Result.gender,
             sp_select_all_id_Result.emailId,
             sp_select_all_id_Result.telephoneNumber,
             sp_select_all_id_Result.dateOfBirth,
             sp_select_all_id_Result.isActive
             );
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sp_select_all_id_Result));
 }