コード例 #1
0
        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());
        }
コード例 #2
0
 public ActionResult Log(int?id)
 {
     if (id != null)
     {
         var viewModel = new ContactLogViewModel(_db.ContactLogs.Find(id));
         return(View(viewModel));
     }
     return(this.View());
 }
コード例 #3
0
ファイル: ContactLog.cs プロジェクト: grimsmath/mms
 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;
 }
コード例 #4
0
ファイル: ContactLog.cs プロジェクト: grimsmath/mms
 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;
 }
コード例 #5
0
        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"));
        }
コード例 #6
0
        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);
        }