public ActionResult Log(ContactLogViewModel viewModel) { if (!ModelState.IsValid) { return(this.View(viewModel)); } else { if (viewModel.ContactLogId > 0) { ContactLog foundLog = _db.ContactLogs.Find(viewModel.ContactLogId); foundLog.Copy(viewModel); } else { var newLog = new ContactLog(viewModel); this._db.ContactLogs.Add(newLog); } this._db.SaveChanges(); Response.Redirect("~/Mentor"); } return(this.View()); }
public ActionResult Log(int?id) { if (id != null) { var viewModel = new ContactLogViewModel(_db.ContactLogs.Find(id)); return(View(viewModel)); } return(this.View()); }
public ContactLog(ContactLogViewModel viewModel) { this.id = viewModel.ContactLogId; this.ContactDate = DateTime.Parse(viewModel.ContactDate); this.ContactTypeId = viewModel.ContactTypeId; this.MentorId = viewModel.MentorId; this.MenteeId = viewModel.MenteeId; this.Details = viewModel.Details; this.ActivityTypeId = viewModel.ActivityTypeId; }
public void Copy(ContactLogViewModel log) { this.id = log.ContactLogId; this.ContactDate = DateTime.Parse(log.ContactDate); this.ContactTypeId = log.ContactTypeId; this.MentorId = log.MentorId; this.MenteeId = log.MenteeId; this.Details = log.Details; this.ActivityTypeId = log.ActivityTypeId; }
public ActionResult LogIn(ContactLogViewModel user) { var result = _contactService.Authorize(user); if (result.Success) { FormsAuthentication.SetAuthCookie(user.Login, false); return(RedirectToAction("Index", "Contact")); } return(View("LogIn")); }
public OneResult <ContactLogViewModel> Authorize(ContactLogViewModel contactView) { OneResult <ContactLogViewModel> resultContact = new OneResult <ContactLogViewModel>(); try { if (_contactService.Authorize(contactView.Login, contactView.Password)) { resultContact.Success = true; } else { resultContact.Success = false; resultContact.Message = "This user does not exist"; } } catch (Exception ex) { resultContact.Success = false; } return(resultContact); }