public PlayerSignInRespModel PlayerSignUp(PlayerSignInReqModel reqModel) { var result = new PlayerSignInRespModel(); var entity = new Player(); entity.Email = reqModel.Email; entity.Name = reqModel.Name; entity.CreatedUTC = DateTime.UtcNow; entity.ModifiedUTC = DateTime.UtcNow; if (_context.Players.Any(x => x.Email == reqModel.Email)) { result.PlayerAlreadyExist = true; result.Error = new SimpleError() { ErrorArg = reqModel.Email, ErrorCode = "error.username-already-taken" }; } else { _context.Players.Add(entity); _context.SaveChanges(); result.PlayerId = entity.Id; } return(result); }
public ActionResult deteleadv(int id) { DemoContext _context = new DemoContext(); Advertisement objadv = new AdvertisementHandler().GetDetailAdvertisement(id); foreach (var child in objadv.Images.ToList()) { String PATH = Request.MapPath("~/" + child.Url); if (System.IO.File.Exists(PATH)) { System.IO.File.Delete(PATH); } if (PATH != null) { _context.Entry(child).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); } } _context.Entry(objadv).State = System.Data.Entity.EntityState.Deleted; // _context.Advertisements.Remove(objadv); _context.SaveChanges(); return(RedirectToAction("index", "home1")); }
public int AddDetail(Orders order) { db.Orders.Add(order); db.SaveChanges(); return(order.OrderId); }
public string AddDetail(Users user) { db.Users.Add(user); db.SaveChanges(); return(user.Email); }
static void Main(string[] args) { DemoContext context = new DemoContext(); //context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Blog blog = new Blog() { Url = "http" }; context.Blogs.Add(blog); context.Entry(blog).Property("CreateTime").CurrentValue = DateTime.Now; context.Entry(blog).Property("LastUpdateTime").CurrentValue = DateTime.Now; context.SaveChanges(); var bloag = context.Blogs.Find(1); Post post = new Post() { Title = "test", Url = "http", Blog = bloag }; context.SaveChanges(); var b = context.Posts.Find(1); Console.WriteLine("Done"); Console.ReadKey(); }
public ActionResult AddCity(FormCollection data) { //Adding Query String User currentUser = (User)Session[WebUtil.CURRENT_USER]; if (currentUser == null) { return(RedirectToAction("Login", "User", new { returnurl = "City/AddCity" })); } if (currentUser.IsRole(WebUtil.ADMIN_ROLE)) { City city = new City(); city.Name = data["cityName"]; city.Province = new Province { ID = Convert.ToInt32(data["ProvinceID"]) }; _context.Entry(city.Province).State = System.Data.Entity.EntityState.Unchanged; _context.Ciities.Add(city); _context.SaveChanges(); return(RedirectToAction("ShowCities", "City")); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult AddProvince(FormCollection data) { //Adding Query String User currentUser = (User)Session[WebUtil.CURRENT_USER]; if (currentUser == null) { return(RedirectToAction("Login", "User", new { returnurl = "Province/AddProvince" })); } if (currentUser.IsRole(WebUtil.ADMIN_ROLE)) { Province province = new Province(); province.Name = data["provinceName"]; province.Country = new Country { ID = Convert.ToInt32(data["countriesList"]) }; _context.Entry(province.Country).State = System.Data.Entity.EntityState.Unchanged; _context.Provinces.Add(province); _context.SaveChanges(); return(RedirectToAction("ShowProvince", "Province")); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public ActionResult Create(Category category) { try { if (category.ID > 0) { Category existCategory = (from c in context.Category where c.ID == category.ID select c).FirstOrDefault(); existCategory.Name = category.Name; existCategory.PhotoFileName = category.PhotoFileName; context.Entry(existCategory).State = EntityState.Modified; context.SaveChanges(); //UploadFile(); return(Json(new { IsSuccess = true, data = "Category Update Successfully!" })); } else { context.Category.Add(category); context.SaveChanges(); return(Json(new { IsSuccess = true, data = "Category Save Successfully!" })); } } catch (Exception e) { throw e; } }
public bool CreateFruit(Fruit fruit) { _context.Fruits.Add(fruit); _context.SaveChanges(); return(true); }
public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.Id) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
//public IActionResult Create() //{ // return View(); //} public IActionResult Create(Employee employee) { _context.Add(employee); _context.SaveChanges(); //return RedirectToAction(nameof(Index)); return(Ok(employee)); }
public int AddDetail(Food food) { db.Foods.Add(food); db.SaveChanges(); return(food.Id); }
public int CreateContainer([FromBody] CreateContainerCommand command) { var container = new Container(command.MaxCapacity); _context.Add(container); _context.SaveChanges(); return(container.Id); }
public void AddPost(PostDto dto) { Validate(dto); var postEntity = Mapper.Map <Post>(dto); _context.Posts.Add(postEntity); _context.SaveChanges(); }
public void Delete(int modelId) { var model = new TModel { Id = modelId }; _ctx.Entities <TModel>().Attach(model); _ctx.Entities <TModel>().Remove(model); _ctx.SaveChanges(); }
public void Post() { var item = _db.Items.Include(x => x.Note).FirstOrDefault(x => x.Id == 1); if (item != null) { item.AddNote(DateTime.Now.ToString("F")); _db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "Id,Name,HOD")] Department department) { if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); }
public ActionResult Create(Person person) { if (ModelState.IsValid) { db.People.Add(person); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(person)); }
public IActionResult Create(Country country) { if (ModelState.IsValid) { db.Countries.Add(country); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Create([Bind(Include = "Id,Name")] Employee employee) { if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public DomainVM addDomain(DomainVM domainVM) { if (domainVM != null) { var domaindata = mapper.Map <Domain>(domainVM); dbContext.tbl_toll.Add(domaindata); dbContext.SaveChanges(); } return(mapper.Map <DomainVM>(dbContext.tbl_toll.Where(a => a.ID == domainVM.ID).Single())); }
public ActionResult Create([Bind(Include = "Id,Title,Note,TotalAmount")] Order order) { if (ModelState.IsValid) { db.Orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Create([Bind(Include = "ItemId,Name,Price,Description,Category,Offer,ImagePath")] Item item) { if (ModelState.IsValid) { db.Item.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Create([Bind(Include = "Id,UserName,ItemId,Quantity")] Carts carts) { if (ModelState.IsValid) { db.Cart.Add(carts); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(carts)); }
public void Insert(Customer customer) { //Bussines Rules if (string.IsNullOrEmpty(customer.Name)) { throw new Exception("Customer name is required"); } _dbSet.Add(customer); _context.SaveChanges(); }
public void Add(User model) { try { db.Set <User>().Add(model); db.SaveChanges(); } catch (Exception ex) { var aa = ex.InnerException.Message; } }
public ActionResult Post([FromBody] Category model) { var category = new Category(); category.Name = model.Name; category.IsActive = true; _db.Add(category); _db.SaveChanges(); return(Ok(category)); }
public int Create(User user) { if (_demoDBContext.Users.Any(a => a.EmailId.ToLower() == user.EmailId.ToLower())) { return(-1); } user.IsActive = true; user.CreatedDate = DateTime.Now; _demoDBContext.Users.Add(user); _demoDBContext.SaveChanges(); return(user.Id); }
public void PaymentDone(int tId) { try { var order = context.Orders.Where(c => c.PaymentId == tId.ToString()).First(); order.PaymentDate = DateTime.Now; context.SaveChanges(); } catch (System.Exception) { throw; } }
public ActionResult Create(Category entity) { if (ModelState.IsValid) { db.Entry <Category>(entity).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); return(RedirectToAction("Index")); } else { return(View(entity)); } }
private void SeedContext(DemoContext context) { //seed some data in var demo = new DemoBaseClass() { NormalAttribute = "TEST" }; context.DemoBaseClasses.Add(demo); var demo1 = new DemoDerivedClass1() { NormalAttribute = "TEST1" }; context.DemoDerivedClassOnes.Add(demo1); var demo2 = new DemoDerivedClass2() { NormalAttribute = "TEST2" }; context.DemoDerivedClassTwos.Add(demo2); var demo3 = new DemoDerivedClass3() { NormalAttribute = "TEST3" }; context.DemoDerivedClassThrees.Add(demo3); context.SaveChanges(); }