Esempio n. 1
0
 public ActionResult UpdateSave(TS model)
 {
     if (ModelState.IsValid)
     {
         using (TSContext db = new TSContext())
         {
             if (db.TSses.Any(item => item.Surname.ToLower() == model.Surname.ToLower() && item.Phone == model.Phone))
             {
                 return(RedirectToAction("Index"));
             }
             if (db.TSses.Any(item => item.Surname.ToLower() == model.Surname.ToLower() && item.Id != model.Id))
             {
                 ModelState.AddModelError("", $"В справочнике уже есть фамилия {model.Surname}");
                 return(View(model));
             }
             if (db.TSses.Any(item => item.Phone == model.Phone && item.Id != model.Id))
             {
                 ModelState.AddModelError("", $"В справочнике уже есть номер {model.Phone}");
                 return(View(model));
             }
             db.Entry(model).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     else
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 2
0
        public FileContentResult ShowImage()
        {
            TSContext dbContext = new TSContext();
            var       imageData = dbContext.Yummies.ToList()[0].Photo;

            return(new FileContentResult(imageData, "image/jpg"));
        }
Esempio n. 3
0
 public ActionResult AddSave(TS model)
 {
     if (ModelState.IsValid)
     {
         using (TSContext db = new TSContext())
         {
             if (db.TSses.Any(item => item.Surname.ToLower() == model.Surname.ToLower()))
             {
                 ModelState.AddModelError("", $"В справочнике уже есть фамилия {model.Surname}");
                 return(View(model));
             }
             if (db.TSses.Any(item => item.Phone == model.Phone))
             {
                 ModelState.AddModelError("", $"В справочнике уже есть номер {model.Phone}");
                 return(View(model));
             }
             db.TSses.Add(model);
             db.SaveChanges();
         }
     }
     else
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 4
0
        public JsonResult Upload()
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i]; //Uploaded file
                                                            //Use the following properties to get file's name, size and MIMEType
                int              fileSize    = file.ContentLength;
                string           fileName    = file.FileName;
                string           mimeType    = file.ContentType;
                System.IO.Stream fileContent = file.InputStream;
                //To save file, use SaveAs method

                YummyViewModel vm = new YummyViewModel();

                var content = new byte[file.ContentLength];
                file.InputStream.Read(content, 0, file.ContentLength);

                TSContext dbContext = new TSContext();
                dbContext.Yummies.ToList()[0].Photo = content;
                dbContext.SaveChanges();
                //assignment.FileLocation = content;


                file.SaveAs(Server.MapPath("~/") + fileName); //File will be saved in application root
            }
            return(Json("Uploaded " + Request.Files.Count + " files"));
        }
Esempio n. 5
0
        public ActionResult <object> Get(string collectionname, string param1, string param2, string param3, string param4, string param5, string param6, string param7)
        {
            TSContext context  = new TSContext("chapa");
            var       list     = context.read(collectionname + "/" + param1 + "/" + param2 + "/" + param3 + "/" + param4 + "/" + param5 + "/" + param6 + "/" + param7, true);
            var       response = new TSResponse();

            return(response.select(list));
        }
Esempio n. 6
0
        public override void Run(TSRuntime runtime, TSContext context)
        {
            object left  = runtime.CalStack.Pop();
            object right = runtime.CalStack.Pop();
            double d     = double.Parse(left.ToString()) + double.Parse(right.ToString());

            runtime.CalStack.Push(d);
        }
Esempio n. 7
0
        public ActionResult Delete(int id)
        {
            TS ts;

            using (TSContext db = new TSContext())
                ts = db.TSses.Find(id);
            return(View(ts));
        }
Esempio n. 8
0
 public ActionResult DeleteSave(TS model)
 {
     using (TSContext db = new TSContext())
     {
         db.TSses.Remove(db.TSses.Find(model.Id));
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 9
0
        public ActionResult Index()
        {
            List <TS> list;

            using (TSContext db = new TSContext())
            {
                list = db.TSses.OrderBy(item => item.Surname).ToList();
            }
            return(View(list));
        }
Esempio n. 10
0
        public static void Main(string[] args)
        {
            var esCtx = new ESContext();

            esCtx.Computers.Add(new Computer()
            {
                Description = "test", CoolingType = "none", Price = 333, Weight = 2
            });
            esCtx.SaveChanges();

            var tsCtx = new TSContext();

            tsCtx.Computers.Add(new TSComputer()
            {
                Description = "test", CoolingType = "none", Price = 333, Weight = 2,
                Server      = new Server()
                {
                    BandWidth = 100
                }
            });
            tsCtx.SaveChanges();
        }
Esempio n. 11
0
 public override void Run(TSRuntime runtime, TSContext context)
 {
     runtime.CalStack.Push(Value);
 }
Esempio n. 12
0
 public MovieDataService(TSContext context)
 {
     _context = context;
 }
Esempio n. 13
0
 public virtual void Run(TSRuntime runtime, TSContext context)
 {
 }
Esempio n. 14
0
 public OwnersController(TSContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public TSRuntime()
 {
     _curContext = new TSContext();
     CalStack    = new Stack <object>();
     VarList     = new List <object>();
 }
Esempio n. 16
0
 public CategoryController(TSContext context)
 {
     _context = context;
 }
Esempio n. 17
0
 public BrandsController(TSContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public WeddingRepository(TSContext db)
 {
     _db = db;
 }
Esempio n. 19
0
 public AdminController(TSContext context)
 {
     _context = context;
 }
Esempio n. 20
0
 public ProvidersController(TSContext context)
 {
     _context = context;
 }
Esempio n. 21
0
 public UserController(TSContext context)
 {
     _context = context;
 }
Esempio n. 22
0
        public ActionResult <object> Get(string collectionname)
        {
            TSContext context = new TSContext("chapa");

            return(context.read(collectionname, true));
        }
 public BillController(TSContext context)
 {
     _context = context;
 }
Esempio n. 24
0
 public ShopsController(TSContext context)
 {
     _context = context;
 }
Esempio n. 25
0
 public ProductsController(TSContext context)
 {
     _context = context;
 }
Esempio n. 26
0
 public InquiryService()
 {
     _dbContext = new TSContext();
 }