Exemple #1
0
        // GET: /ContactList/ContactList/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContactList contactList = _contactListService.FindById((int)id);

            if (contactList == null)
            {
                return(HttpNotFound());
            }
            ContactListViewModel contactListViewModel = contactList.MapModelToViewModel();

            contactListViewModel.CreatedBy = _identityUserService.FindUserNameById(contactList.UserId);
            return(PartialView("_Details", contactListViewModel));
        }
        //public ActionResult Edit(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    UserContactList userContactList = _userContactListService.FindById((int)id);
        //    if (userContactList == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return PartialView("_Edit", userContactList.MapModelToViewModel());
        //}

        //// POST: /ContactList/UserContactList/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "Id,UserName,ContactListName")] UserContactListViewModel userContactListViewModel)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        UserContactList userContactList = _userContactListService.FindById(userContactListViewModel.Id);
        //        userContactList.UserId = _identityUserService.FindUserIdByName(userContactListViewModel.UserName);

        //        IContactListService _contactListService = new EfContactListService(_uow);
        //        userContactList.ContactListId = _contactListService.Find(r => r.Name == userContactListViewModel.ContactListName).Id;
        //        _uow.SaveChanges();
        //        return Json(new { success = true });
        //    }
        //    return PartialView("_Edit", userContactListViewModel);
        //}

        // GET: /ContactList/UserContactList/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserContactList userContactList = _userContactListService.FindById((int)id);

            if (userContactList == null)
            {
                return(HttpNotFound());
            }
            //UserContactListViewModel contactListViewModel = contactList.MapModelToViewModel();
            UserContactListViewModel contactListViewModel = new UserContactListViewModel();

            contactListViewModel.ContactListName = _contactListService.FindById(userContactList.ContactListId).Name;
            contactListViewModel.UserName        = _identityUserService.FindUserNameById(userContactList.UserId);
            return(PartialView("_Delete", contactListViewModel));
        }