示例#1
0
        public ActionResult AddAjax(ContactInfoViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (_iContactInfoService.Create(viewModel) > 0)
                    {
                        InformLog("Data saved successfully.", "Contact saved.");
                        return Json(new { msg = "Data saved successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        InformLog("Data could not saved.", "Contact could not saved.");
                        return Json(new { msg = "Data could not saved.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet);
                    }

                }

                InformLog("Model could not valided.", "Contact could not saved.");
                return Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                ErrorLog(ex);
                return Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }
 public int Delete(ContactInfoViewModel contactInfoViewModel)
 {
     var deleteContactInfo = GetContactInfo(contactInfoViewModel.ContactInfoId);
     var contactInfo = EmContactInfo.SetToModel(deleteContactInfo);
     _iContactInfoRepository.Delete(contactInfo);
     return Save();
 }
示例#3
0
        public static ContactInfoViewModel SetToViewModel(ContactInfo contactInfo)
        {
            var viewModel = new ContactInfoViewModel
                                {
                                    ContactInfoId = contactInfo.ContactInfoId,
                                    FirstName = contactInfo.FirstName,
                                    LastName = contactInfo.LastName,
                                    Sex = contactInfo.Sex,
                                    DateOfBirth = contactInfo.DateOfBirth,
                                    Email = contactInfo.Email,
                                    PresentAddress = contactInfo.PresentAddress,
                                    PermanentAddress = contactInfo.PermanentAddress,
                                    PhoneNumber = contactInfo.PhoneNumber,
                                    MobileNumber = contactInfo.MobileNumber,
                                    AlternativeMobileNumber = contactInfo.AlternativeMobileNumber,
                                    FacebookProfile = contactInfo.FacebookProfile,
                                    LinkedInProfile = contactInfo.LinkedInProfile,
                                    GooglePlusProfile = contactInfo.GooglePlusProfile,
                                    NationalIdNumber = contactInfo.NationalIdNumber,
                                    PassportNumber = contactInfo.PassportNumber,
                                    ThumbImageUrl = contactInfo.ThumbImageUrl,
                                    SmallImageUrl = contactInfo.SmallImageUrl
                                };

            return viewModel;
        }
示例#4
0
        public static ContactInfoViewModel SetToViewModel(ContactInfo contactInfo)
        {
            var viewModel = new ContactInfoViewModel
            {
                ContactInfoId           = contactInfo.ContactInfoId,
                FirstName               = contactInfo.FirstName,
                LastName                = contactInfo.LastName,
                Sex                     = contactInfo.Sex,
                DateOfBirth             = contactInfo.DateOfBirth,
                Email                   = contactInfo.Email,
                PresentAddress          = contactInfo.PresentAddress,
                PermanentAddress        = contactInfo.PermanentAddress,
                PhoneNumber             = contactInfo.PhoneNumber,
                MobileNumber            = contactInfo.MobileNumber,
                AlternativeMobileNumber = contactInfo.AlternativeMobileNumber,
                FacebookProfile         = contactInfo.FacebookProfile,
                LinkedInProfile         = contactInfo.LinkedInProfile,
                GooglePlusProfile       = contactInfo.GooglePlusProfile,
                NationalIdNumber        = contactInfo.NationalIdNumber,
                PassportNumber          = contactInfo.PassportNumber,
                ThumbImageUrl           = contactInfo.ThumbImageUrl,
                SmallImageUrl           = contactInfo.SmallImageUrl
            };

            return(viewModel);
        }
示例#5
0
        public ActionResult EditAjax(int id, ContactInfoViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ContactInfoViewModel editViewModel = _iContactInfoService.GetContactInfo(id);
                    if (editViewModel != null)
                    {
                        if (_iContactInfoService.Create(editViewModel) > 0)
                        {
                            InformLog("Data updated successfully.", "Contact updated.");
                            return Json(new { msg = "Data updated successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            InformLog("Data could not updated.", "Contact could not updated.");
                            return Json(new { msg = "Data could not updated.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet);
                        }

                    }

                    InformLog("This data are missing.", "Contact could not updated.");
                    return Json(new { msg = "This data are missing.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet);
                }

                InformLog("Model could not valided.", "Contact could not updated.");
                return Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                ErrorLog(ex);
                return Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }
 public int Update(ContactInfoViewModel contactInfoViewModel)
 {
     var contactInfo = EmContactInfo.SetToModel(contactInfoViewModel);
     _iContactInfoRepository.Update(contactInfo);
     return Save();
 }