// PUT api/Friend/5 public IHttpActionResult PutFriend(int id, Friend friend) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != friend.ID) { return(BadRequest()); } db.Entry(friend).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FriendExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id,Name,Phone,Email,City")] Friend friend) { if (ModelState.IsValid) { db.Friends.Add(friend); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friend)); }
public ActionResult Create([Bind(Include = "indeks,id,ime,mestonaziveenje")] FriendModel friendModel) { if (ModelState.IsValid) { db.Friends.Add(friendModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friendModel)); }
public ActionResult Create([Bind(Include = "friendId,name,place")] Friend friend) { if (ModelState.IsValid) { db.Friends.Add(friend); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friend)); }
public ActionResult Create([Bind(Include = "ID,name,phone,email")] friend friend) { if (ModelState.IsValid) { db.friends.Add(friend); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friend)); }
public ActionResult Create([Bind(Include = "Id,Name,Phone,Email,Gender")] Info info) { if (ModelState.IsValid) { db.Infoes.Add(info); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(info)); }
public ActionResult Create([Bind(Include = "ID,FriendID,Name,Hometown")] FriendModel friendModel) { if (ModelState.IsValid) { db.Friends.Add(friendModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friendModel)); }
public ActionResult EditFriend(FriendModel EditFriend) { if (!ModelState.IsValid) { return(View("EditFriend", EditFriend)); } var update = _context.allfriends.ToList().Single(i => i.Id == EditFriend.Id); update.Ime = EditFriend.Ime; update.Id = EditFriend.Id; update.MestoZiveenje = EditFriend.MestoZiveenje; _context.SaveChanges(); return(View("AllFriends", _context.allfriends.ToList())); }
public ActionResult Add(FriendAddViewModel viewModel) { GoogleMapsAPI maps = GoogleMapsAPI.getInstance(); string[] location = maps.getAddressInfoByStreet(viewModel.friend.street); if (maps.statusCode == GoogleMapsAPI.RESPONSE_OK) { // grab the latitude and longitude and store them viewModel.friend.latitude = location[0]; viewModel.friend.longitude = location[1]; viewModel.friend.full_address = location[2]; // check if the friend already exists var check = (from friendList in db.friends where friendList.full_address == viewModel.friend.full_address && friendList.name == viewModel.friend.name select friendList).FirstOrDefault(); if (check != null) { return(RedirectToAction("Add", new { message = 0 })); } db.friends.Add((Friend)viewModel.friend); db.SaveChanges(); } else if (maps.statusCode == GoogleMapsAPI.RESPONSE_NOT_FOUND) { return(RedirectToAction("Add", new { message = 1 })); } else { return(RedirectToAction("Add", new { message = 2 })); } return(RedirectToAction("Index")); }
public ActionResult CreateNew(Friend friend) { context.friends.Add(friend); context.SaveChanges(); return(RedirectToAction("Index")); }