public void CanCompareDiveLocations() { DiveLocation instance = new DiveLocation(); User user = new User(); user.LoginCount = 3; user.LoginId = "larry"; user.Password = "******"; user.Created = System.DateTime.Now; user.LastModified = System.DateTime.Now; instance.Title = "Goodenough Spring"; instance.User = user; DiveLocation instanceToCompareTo = new DiveLocation(); instanceToCompareTo.Title = "Goodenough Spring"; User user2 = new User(); user.LoginCount = 3; user.LoginId = "larry"; user.Password = "******"; user.Created = System.DateTime.Now; user.LastModified = System.DateTime.Now; //instanceToCompareTo.User = user2; //breaks instanceToCompareTo.User = user; // works instance.ShouldEqual(instanceToCompareTo); }
public User FindUser(string userId) { User user = new User(); Dictionary<string, object> dictionary = new Dictionary<string, object>(); dictionary.Add("LoginId", userId); //dictionary.Add("Password", password); user = userRepository.FindOne(dictionary); return user; }
public User Save(User user) { try { userRepository.SaveOrUpdate(user); userRepository.DbContext.CommitChanges(); } catch (Exception e) { log.Error("Unable to save user " + user.LoginId, e); throw e; } return user; }
public ActionResult Create(DiveTypeModel model) { DiveType diveType = new DiveType(); user = userServices.FindUser(this.User.Identity.Name); diveType.User = user; diveType.Title = model.Title; diveType.Notes = model.Notes; diveType.Created = DateTime.Now; diveType.LastModified = DateTime.Now; diveTypeRepository.SaveOrUpdate(diveType); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The diveType was successfully created."; return RedirectToAction("Index"); return View(model); }
public ActionResult Create() { user = userServices.FindUser(this.User.Identity.Name); systemUser = userServices.FindUser("system"); DiverCertificationModel model = new DiverCertificationModel(); IList<SelectListItem> DiveAgencyListItems = diveAgencyServices.BuildList(null); model.DiveAgencyListItems = DiveAgencyListItems; model.DiveAgencyListItems = DiveAgencyListItems.OrderBy(m => m.Text).ToList(); //this works too as opposed to the following 2 lines var sortedList = from row in DiveAgencyListItems orderby row.Text select row; model.DiveAgencyListItems = sortedList.ToList(); int firstAgencyId = int.Parse(model.DiveAgencyListItems[0].Value); IList<SelectListItem> CertificationListItems = certificationServices.BuildSelectListForAgency(firstAgencyId,null, user.Id, systemUser.Id); model.CertificationListItems = CertificationListItems; model.InstructorListItems = instructorServices.BuildListItems(null, user.Id); return View(model); }
public ActionResult Create(DiveSitesModel diveSitesModel) { user = userServices.FindUser(this.User.Identity.Name); if (ModelState.IsValid) { diveSitesModel.DiveSite.User = user; diveSitesModel.DiveSite.DiveLocation = locationServices.Get(diveSitesModel.DiveSite.DiveLocationId); diveSitesModel.DiveSite.Created = DateTime.Now; diveSitesModel.DiveSite.LastModified = DateTime.Now; diveSiteServices.Save(diveSitesModel.DiveSite); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The diveSite was successfully created."; return RedirectToAction("Index"); } diveSitesModel.DiveLocationsListItems = BuildLocationList(null); return View(diveSitesModel); }
public ActionResult Create(CertificationModel certificationModel) { user = userServices.FindUser(this.User.Identity.Name); if (ModelState.IsValid) { Certification certification = new Certification(); certification.User = user; certification.Title = certificationModel.Title; certification.Notes = certificationModel.Notes; certification.DiveAgency = diveAgencyServices.GetDiveAgency(certificationModel.DiveAgencyId); certification.Created = DateTime.Now; certification.LastModified = DateTime.Now; certificationServices.Save(certification); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The certification was successfully created."; return RedirectToAction("Index"); } certificationModel.DiveAgencyListItems = BuildList(null); return View(certificationModel); }
public ActionResult Create(DiveLocation diveLocation) { User user; if (ViewData.ModelState.IsValid) { diveLocation.Created = System.DateTime.Now; diveLocation.LastModified = System.DateTime.Now; user = userServices.FindUser(this.User.Identity.Name); diveLocation.User = user; diveLocation.UserId = user.Id; locationServices.Create(diveLocation); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The diveLocation was successfully created."; return RedirectToAction("Index"); } DiveLocationFormViewModel viewModel = DiveLocationFormViewModel.CreateDiveLocationFormViewModel(); viewModel.DiveLocation = diveLocation; return View(viewModel); }
public ActionResult Create(DiverCertificationModel model) { user = userServices.FindUser(this.User.Identity.Name); Diver diver = diverServices.GetDiverByContact(user.Contact.Id); if (ModelState.IsValid) { DiverCertification diverCertification = new DiverCertification(); diverCertification.Diver = diver; diverCertification.Notes = model.Notes; diverCertification.CertificationNum = model.CertificationNum; diverCertification.Certified = model.Certified; diverCertification.Instructor = instructorServices.GetInstructor(model.InstructorId); diverCertification.Certification = certificationServices.Get(model.CertificationId); diverCertification.Created = System.DateTime.Now; diverCertification.LastModified = System.DateTime.Now; diverCertificationServices.Save(diverCertification); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The certification was successfully created."; return RedirectToAction("Index"); } return View(model); }
public ActionResult Index() { user = userServices.FindUser(this.User.Identity.Name); IList<Certification> certifications = certificationServices.GetAllForUser(user.Id); certifications = certifications.OrderBy(m => m.DiveAgency.Contact.Company).ToList(); return View(certifications); }
public ActionResult RetrieveAgencyCertifications(DiverCertificationModel model) { user = userServices.FindUser(this.User.Identity.Name); systemUser = userServices.FindUser("system"); IList<SelectListItem> DiveAgencyListItems = diveAgencyServices.BuildList(null); model.DiveAgencyListItems = DiveAgencyListItems; model.DiveAgencyListItems = DiveAgencyListItems.OrderBy(m => m.Text).ToList(); //this works too as opposed to the following 2 lines var sortedList = from row in DiveAgencyListItems orderby row.Text select row; model.DiveAgencyListItems = sortedList.ToList(); foreach (var diveAgencyListItem in DiveAgencyListItems) { if (diveAgencyListItem.Value == model.DiveAgencyId.ToString()) { diveAgencyListItem.Selected = true; } } IList<SelectListItem> CertificationListItems = certificationServices.BuildSelectListForAgency(model.DiveAgencyId, null, user.Id, systemUser.Id); model.CertificationListItems = CertificationListItems; model.InstructorListItems = instructorServices.BuildListItems(null, user.Id); return View("Create",model); }
public ActionResult Index() { user = userServices.FindUser(this.User.Identity.Name); IList<DiverCertification> diverCertifications = diverCertificationServices.GetAll(user.Contact.Divers.ElementAt(0).Id); diverCertifications = diverCertifications.OrderBy(m => m.Certification.Title).ToList(); return View(diverCertifications); }
private IList<DiveLocation> GetDiveLocations() { user = userServices.FindUser(this.User.Identity.Name); systemUser = userServices.FindUser("system"); IList<DiveLocation> locations = locationServices.GetAllSystemAndUser(systemUser.Id, user.Id); return locations; }
public virtual bool Equals(User obj) { if (obj == null) return false; if (Equals(Created, obj.Created) == false) return false; if (Equals(LastModified, obj.LastModified) == false) return false; if (Equals(LoginCount, obj.LoginCount) == false) return false; if (Equals(LoginId, obj.LoginId) == false) return false; if (Equals(Password, obj.Password) == false) return false; if (Equals(Id, obj.Id) == false) return false; return true; }
private User RetrieveUser(User user) { User retVal; Dictionary<string, object> dictionary = new Dictionary<string, object>(); dictionary.Add("LoginId", user.LoginId); retVal = userRepository.FindOne(dictionary); return retVal; }
private User RetrieveUser(string username) { User user = new User(); User retVal; user.LoginId = username; retVal = RetrieveUser(user); return retVal; }
public ActionResult IndexForLocation(int locationId) { user = userServices.FindUser(this.User.Identity.Name); systemUser = userServices.FindUser("system"); IList<DiveSite> diveSites; diveSites = diveSiteServices.GetDiveSitesForLocation(locationId, systemUser.Id, user.Id); DiveSitesIndexModel viewModel = new DiveSitesIndexModel(); viewModel.DiveSiteList = diveSites; return View("Index", viewModel); }
public ActionResult Index() { user = userServices.FindUser(this.User.Identity.Name); IList<Contact> contacts = contactServices.GetAllForUser(user.Id); IList<ContactsIndexModel> contactsModelList = new List<ContactsIndexModel>(); ContactsIndexModel contactsModel; foreach (Contact c in contacts) { contactsModel = new ContactsIndexModel(); contactsModel.ContactId = c.Id; contactsModel.Company = c.Company; contactsModel.FirstName = c.FirstName; contactsModel.LastName = c.LastName; contactsModel.Email = c.Email; contactsModel.User = c.User.LoginId; contactsModel.tags = getTags(c); contactsModelList.Add(contactsModel); } return View(contactsModelList); }
public ActionResult Index() { systemUser = userServices.FindUser("system"); user = userServices.FindUser(this.User.Identity.Name); IList<DiveLocation> diveLocations = locationServices.GetAllSystemAndUser(systemUser.Id, user.Id); return View(diveLocations); }
public ActionResult EditProfile() { user = userServices.FindUser(this.User.Identity.Name); if (user.Contact == null) { Contact contact = new Contact(); contact.User = user; contact.Created = System.DateTime.Now; contactServices.Save(contact); user.Contact = contact; userServices.Save(user); } return (Edit(user.Contact.Id)); }
public ActionResult IndexForAgency(int agencyId) { user = userServices.FindUser(this.User.Identity.Name); systemUser = userServices.FindUser("system"); IList<Certification> certifications; certifications = certificationServices.GetCertificationsForAgency(agencyId, systemUser.Id, user.Id); return View("Index", certifications); }
private void saveNewContact(ContactModel model) { this.user = userServices.FindUser(this.User.Identity.Name); Contact contact = new Contact(); contact = UpdateContactFromModel(contact, model); contact.User = this.user; contact.Created = DateTime.Now; contact.LastModified = DateTime.Now; contactServices.Save(contact); if (model.isDiver) { Diver diver = new Diver(); diver.Contact = contact; diverServices.Save(diver); } if (model.isInstructor) { Instructor instructor = new Instructor(); instructor.Contact = contact; instructorServices.Save(instructor); } if (model.isAgency) { DiveAgency agency = new DiveAgency(); agency.Contact = contact; diveAgencyServices.Save(agency); } if (model.isManufacturer) { Manufacturer manufacturer = new Manufacturer(); manufacturer.Contact = contact; manufacturerServices.Save(manufacturer); } if (model.isDiveShop) { DiveShop diveShop = new DiveShop(); diveShop.Contact = contact; diveShopServices.Save(diveShop); } }
public ActionResult Index() { user = userServices.FindUser(this.User.Identity.Name); DiveSitesIndexModel model = new DiveSitesIndexModel(); IList<DiveSite> diveSites = diveSiteServices.GetAllForUser(user.Id); diveSites = diveSites.OrderBy(m => m.Title).ToList(); model.DiveSiteList = diveSites; return View(model); }