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")); }
public FileContentResult ShowImage() { TSContext dbContext = new TSContext(); var imageData = dbContext.Yummies.ToList()[0].Photo; return(new FileContentResult(imageData, "image/jpg")); }
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")); }
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")); }
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)); }
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); }
public ActionResult Delete(int id) { TS ts; using (TSContext db = new TSContext()) ts = db.TSses.Find(id); return(View(ts)); }
public ActionResult DeleteSave(TS model) { using (TSContext db = new TSContext()) { db.TSses.Remove(db.TSses.Find(model.Id)); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Index() { List <TS> list; using (TSContext db = new TSContext()) { list = db.TSses.OrderBy(item => item.Surname).ToList(); } return(View(list)); }
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(); }
public override void Run(TSRuntime runtime, TSContext context) { runtime.CalStack.Push(Value); }
public MovieDataService(TSContext context) { _context = context; }
public virtual void Run(TSRuntime runtime, TSContext context) { }
public OwnersController(TSContext context) { _context = context; }
public TSRuntime() { _curContext = new TSContext(); CalStack = new Stack <object>(); VarList = new List <object>(); }
public CategoryController(TSContext context) { _context = context; }
public BrandsController(TSContext context) { _context = context; }
public WeddingRepository(TSContext db) { _db = db; }
public AdminController(TSContext context) { _context = context; }
public ProvidersController(TSContext context) { _context = context; }
public UserController(TSContext context) { _context = context; }
public ActionResult <object> Get(string collectionname) { TSContext context = new TSContext("chapa"); return(context.read(collectionname, true)); }
public BillController(TSContext context) { _context = context; }
public ShopsController(TSContext context) { _context = context; }
public ProductsController(TSContext context) { _context = context; }
public InquiryService() { _dbContext = new TSContext(); }