public async Task <IActionResult> Edit(int id, [Bind("Id,VetName,VetSurname,Office,Address,OpeningHours,IsOpen")] VetModel vetModel) { if (id != vetModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vetModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VetModelExists(vetModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vetModel)); }
public static string setStatus(VetModel vet) { string status = null; if (vet.Color == "purple") { status = "Barınak"; } else if (vet.Color == "gray") { status = "Bilinmiyor"; } else if (vet.Color == "green") { status = "Açık"; } else if (vet.Color == "red") { status = "Kapalı"; } else if (vet.Color == "orange") { status = "Yalnızca Acil Durumlar"; } return(status); }
public void InsertVet(VetModel vet) { vet.IdVet = Guid.NewGuid(); dbContext.Vets.InsertOnSubmit(MapModelToDbObject(vet)); dbContext.SubmitChanges(); }
public async Task <IActionResult> Create([Bind("Id,VetName,VetSurname,Office,Address,OpeningHours,IsOpen")] VetModel vetModel) { if (ModelState.IsValid) { _context.Add(vetModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vetModel)); }
public async Task <List <VetModel> > GetVetsInCity(string city) { List <VetModel> list = new List <VetModel>(); try { var query = ParseObject.GetQuery("UserVets").WhereEqualTo("city", city); var final = await query.FindAsync(); foreach (ParseObject obj in final) { var model = new VetModel() { Address = (obj.ContainsKey("address") == true) ? obj.Get <string>("address") : null, CellNumber = (obj.ContainsKey("cellNumber") == true) ? obj.Get <string>("cellNumber") : null, City = (obj.ContainsKey("city") == true) ? obj.Get <string>("city") : null, Town = (obj.ContainsKey("town") == true) ? obj.Get <string>("town") : null, Email = (obj.ContainsKey("email") == true) ? obj.Get <string>("email") : null, FacebookPage = (obj.ContainsKey("facebookPage") == true) ? obj.Get <string>("facebookPage") : null, InstagramAccount = (obj.ContainsKey("instagramAccount") == true) ? obj.Get <string>("instagramAccount") : null, TwitterAccount = (obj.ContainsKey("twitterAccount") == true) ? obj.Get <string>("twitterAccount") : null, WebAddress = (obj.ContainsKey("webAddress") == true) ? obj.Get <string>("webAddress") : null, webURLAddress = (obj.ContainsKey("webURLAddress") == true) ? obj.Get <string>("webURLAddress") : null, IsActive = (obj.ContainsKey("isActive") == true) ? obj.Get <bool>("isActive") : false, IsConfirmed = (obj.ContainsKey("isConfirmed") == true) ? obj.Get <bool>("isConfirmed") : false, IsMember = (obj.ContainsKey("isMember") == true) ? obj.Get <bool>("isMember") : false, IsNew = (obj.ContainsKey("isNew") == true) ? obj.Get <bool>("isNew") : false, Location = obj.Get <ParseGeoPoint>("location"), Name = (obj.ContainsKey("name") == true) ? obj.Get <string>("name") : null, PhoneNumber = (obj.ContainsKey("phoneNumber") == true) ? obj.Get <string>("phoneNumber") : null, Services = (obj.ContainsKey("services") == true) ? (IList <object>)obj.Get <object>("services") : null, WorkingDaysAndHours = (obj.ContainsKey("workingDaysAndHours") == true) ? (IList <object>)obj.Get <object>("workingDaysAndHours") : null, Logo = (obj.ContainsKey("logo") == true) ? obj.Get <ParseFile>("logo").Url.AbsoluteUri : "ms-appx:///Assets/Logos/flyoutLogo.png", Images = (obj.ContainsKey("images") == true) ? (IList <object>)obj.Get <object>("images") : null }; model.Color = VetHelper.setColor(model); model.Status = VetHelper.setStatus(model); model.MapPin = "ms-appx:///Assets/MapPins/" + model.Color + ".png"; model.Style = VetHelper.setStyle(model); list.Add(model); } return(list); } catch (Exception) { return(list); } }
public void UpdateVet(VetModel vet) { Vet dbVet = dbContext.Vets.FirstOrDefault(x => x.IdVet == vet.IdVet); if (vet != null) { dbVet.IdVet = vet.IdVet; dbVet.FirstName = vet.FirstName; dbVet.LastName = vet.LastName; dbVet.Specialization = vet.Specialization; dbVet.Phone = vet.Phone; dbVet.Email = vet.Email; dbContext.SubmitChanges(); } }
public ActionResult Create(FormCollection collection) { try { VetModel vetModel = new VetModel(); UpdateModel(vetModel); vetRepository.InsertVet(vetModel); return(RedirectToAction("Index")); } catch { return(View("CreateVet")); } }
public ActionResult Edit(Guid id, FormCollection collection) { try { VetModel vetModel = new VetModel(); UpdateModel(vetModel); vetRepository.UpdateVet(vetModel); return(RedirectToAction("Index")); } catch { return(View("EditVet")); } }
private Vet MapModelToDbObject(VetModel vet) { Vet dbVet = new Vet(); if (vet != null) { dbVet.IdVet = vet.IdVet; dbVet.FirstName = vet.FirstName; dbVet.LastName = vet.LastName; dbVet.Specialization = vet.Specialization; dbVet.Phone = vet.Phone; dbVet.Email = vet.Email; return(dbVet); } return(null); }
private VetModel MapDbObjectToModel(Vet dbVet) { VetModel vet = new VetModel(); if (dbVet != null) { vet.IdVet = dbVet.IdVet; vet.FirstName = dbVet.FirstName; vet.LastName = dbVet.LastName; vet.Specialization = dbVet.Specialization; vet.Phone = dbVet.Phone; vet.Email = dbVet.Email; return(vet); } return(null); }
private void PinToMap(VetModel vet) { BasicGeoposition pos = new BasicGeoposition() { Latitude = vet.Location.Latitude, Longitude = vet.Location.Longitude }; MapIcon icon = new MapIcon() { Visible = true, Location = new Geopoint(pos), NormalizedAnchorPoint = new Point() { X = 0.32, Y = 0.78 }, Image = RandomAccessStreamReference.CreateFromUri(new Uri(vet.MapPin, UriKind.RelativeOrAbsolute)) }; map.MapElements.Add(icon); }
public static StyleModel setStyle(VetModel vet) { if (vet.Color == "green") { IList <object> list = vet.WorkingDaysAndHours.ToList(); Dictionary <string, string> dictionary = getDictionary(list[0]); if (dictionary["allDay"] != null && dictionary["allDay"] == "True") { return(new StyleModel() { StyleStatus = "7 / 24 Açık", Foreground = "#2cb796", Background = "#d2f2ed" }); } else { return(new StyleModel() { StyleStatus = "Açık", Foreground = "#2cb796", Background = "#d2f2ed" }); } } else if (vet.Color == "purple") { return(new StyleModel() { StyleStatus = "Belediye Merkezi", Foreground = "#605bad", Background = "#ddddf9" }); } else if (vet.Color == "red") { return(new StyleModel() { StyleStatus = "Kapalı", Foreground = "#dd3d3f", Background = "#ffd2cc" }); } else if (vet.Color == "orange") { return(new StyleModel() { StyleStatus = "Acil Aramalar", Foreground = "#f5991a", Background = "#ffeacb" }); } else { return(new StyleModel() { StyleStatus = "Bilinmiyor", Foreground = "#aaaaaa", Background = "#ededed" }); } }
public static string setColor(VetModel vet) { string color = null; if (vet.IsActive == true) { if (vet.IsMember == false) { color = "gray"; } else if (vet.IsMember == true) { if (vet.IsConfirmed == false) { color = "purple"; } else if (vet.IsConfirmed == true) { IList <object> list = vet.WorkingDaysAndHours.ToList(); Dictionary <string, string> dictionary = getDictionary(list[0]); if (dictionary["allDay"] == "True") { color = "green"; } else { var dayOfWeek = DateTime.Now.DayOfWeek.ToString(); #region Saturday if (dayOfWeek == "Saturday") { if (dictionary.ContainsKey("saturday") && dictionary["saturday"] == "True") { if (dictionary["saturdayOpenHour"] != null || dictionary["saturdayCloseHour"] != null) { var nowTime = DateTime.Now.ToLocalTime().TimeOfDay; var addTime = DateTime.Parse("1.01.2000 04:00:00").ToUniversalTime().TimeOfDay; var openTime = DateTime.Parse(dictionary["saturdayOpenHour"]).ToUniversalTime().TimeOfDay + addTime; var closeTime = DateTime.Parse(dictionary["saturdayCloseHour"]).ToUniversalTime().TimeOfDay + addTime; if ((openTime < nowTime) && (nowTime < closeTime)) { color = "green"; } else { if (dictionary["emergencyCall"] == "True") { color = "orange"; } else { color = "red"; } } } else { color = "gray"; } } else { color = "gray"; } } #endregion #region Sunday else if (dayOfWeek == "Sunday") { if (dictionary.ContainsKey("sunday") && dictionary["sunday"] == "True") { if (dictionary["sundayOpenHour"] != null || dictionary["sundayCloseHour"] != null) { var nowTime = DateTime.Now.ToLocalTime().TimeOfDay; var addTime = DateTime.Parse("1.01.2000 04:00:00").ToUniversalTime().TimeOfDay; var openTime = DateTime.Parse(dictionary["sundayOpenHour"]).ToUniversalTime().TimeOfDay + addTime; var closeTime = DateTime.Parse(dictionary["sundayCloseHour"]).ToUniversalTime().TimeOfDay + addTime; if ((openTime < nowTime) && (nowTime < closeTime)) { color = "green"; } else { if (dictionary["emergencyCall"] == "True") { color = "orange"; } else { color = "red"; } } } else { color = "gray"; } } else { color = "gray"; } } #endregion #region WeekDays else { if (dictionary["workingOpenHour"] != null || dictionary["workingCloseHour"] != null) { var nowTime = DateTime.Now.ToLocalTime().TimeOfDay; var addTime = DateTime.Parse("1.01.2000 04:00:00").ToUniversalTime().TimeOfDay; var openTime = DateTime.Parse(dictionary["workingOpenHour"]).ToUniversalTime().TimeOfDay + addTime; var closeTime = DateTime.Parse(dictionary["workingCloseHour"]).ToUniversalTime().TimeOfDay + addTime; if ((openTime < nowTime) && (nowTime < closeTime)) { color = "green"; } else { if (dictionary["emergencyCall"] != null) { if (dictionary["emergencyCall"] == "True") { color = "orange"; } else { color = "red"; } } else { color = "gray"; } } } else { color = "gray"; } } #endregion } } } else { color = "gray"; } } else { color = "gray"; } return(color); }
// GET: Vet/Edit/5 public ActionResult Edit(Guid id) { VetModel vetModel = vetRepository.GetVetById(id); return(View("EditVet", vetModel)); }
// GET: Vet/Details/5 public ActionResult Details(Guid id) { VetModel vetModel = vetRepository.GetVetById(id); return(View("VetDetails", vetModel)); }
// GET: Vet/Delete/5 public ActionResult Delete(Guid id) { VetModel vetModel = vetRepository.GetVetById(id); return(View("DeleteVet", vetModel)); }