コード例 #1
0
        public ActionResult GetAllContactDetails()
        {
            ContactRepo ContactRepoObj = new ContactRepo();

            ModelState.Clear();
            return(View(ContactRepoObj.GetAllContacts()));
        }
コード例 #2
0
 public HomeController()
 {
     cs = new CustomerRepo();
     pr = new ProductRepo();
     cr = new CartRepo();
     cp = new ContactRepo();
 }
コード例 #3
0
        public async Task <ActionResult> UpdateContactDetail(string ContactId, string FirstName, string LastName, string Title, string Webaddress, string Address1,
                                                             string Address2, string Suburb, string State, string PostalCode, string Workphone, string Mobile, string Fax, string Homephone, string Email)
        {
            ClaimTeamLoginModel client = (ClaimTeamLoginModel)Session[SessionHelper.claimTeamLogin];
            ContactUpdateModel  model  = new ContactUpdateModel();

            model.ContactId  = ContactId;
            model.FirstName  = FirstName;
            model.LastName   = LastName;
            model.Title      = Title;
            model.Webaddress = Webaddress;
            model.Address1   = Address1;
            model.Address2   = Address2;
            model.Suburb     = Suburb;
            model.State      = State;
            model.PostalCode = PostalCode;
            model.Workphone  = Workphone;
            model.Mobile     = Mobile;
            model.Fax        = Fax;
            model.Homephone  = Homephone;
            model.Email      = Email;
            ContactRepo contactRepo = new ContactRepo();
            bool        result      = await contactRepo.UpdateContact(model, client.UserId);

            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public IndexController()
 {
     cs = new CustomerRepo();
     pr = new ProductRepo();
     cr = new CartRepo();
     cp = new ContactRepo();
     op = new OrderRepo();
 }
コード例 #5
0
        // GET: Home
        public ActionResult Index()
        {
            ContactRepo    c   = new ContactRepo();
            List <Contact> con = c.GetContact();

            ViewBag.contacts = con;
            return(View());
        }
コード例 #6
0
 public IActionResult SaveContact([FromBody] ContactModel contact)
 {
     if (ContactRepo.SaveContact(contact) != null)
     {
         return(Ok(contact));
     }
     return(StatusCode(500));
 }
コード例 #7
0
        public ActionResult UpdateContact(int id)
        {
            ContactRepo ContactRepoObj = new ContactRepo();



            return(View(ContactRepoObj.GetAllContacts().Find(Cont => Cont.Id == id)));
        }
コード例 #8
0
        public IActionResult GetContact(int contactId)
        {
            var contact = ContactRepo.GetContact(contactId);

            if (contact != null)
            {
                return(new ObjectResult(contact));
            }
            return(StatusCode(500));
        }
コード例 #9
0
        public IActionResult GetContactCount(int company)
        {
            var count = ContactRepo.GetContactCount(company);

            if (count > -1)
            {
                return(new ObjectResult(count));
            }
            return(StatusCode(500));
        }
コード例 #10
0
        public IActionResult GetAllContact(int pp, int page)
        {
            var contactList = ContactRepo.GetAllContact(pp, page);

            if (contactList != null)
            {
                return(new ObjectResult(contactList));
            }
            return(StatusCode(500));
        }
コード例 #11
0
        public ActionResult Edit(int id)
        {
            var data = ContactRepo.Find(id);

            if (data == null)
            {
                throw new InvalidOperationException("操作錯誤");
            }
            return(View(data));
        }
コード例 #12
0
        public ActionResult SendForm(ContactVM model)
        {
            var cRepo = new ContactRepo();

            cRepo.AddContactDetails(model.Name, model.Email, model.Message);

            var template = UmbracoContext.Application.Services.FileService.GetTemplate(CurrentPage.TemplateId);
            var path     = template.VirtualPath;

            return(View(path, ControllerHelpers.GetHomeModel(CurrentPage, model, true)));
        }
コード例 #13
0
        public void CreateContact_FirstAndLastIsNullOrWhiteSpace()
        {
            var repo    = new ContactRepo(null);
            var contact = new Contact()
            {
                FirstName = null, LastName = null
            };

            var dto = repo.CreateContact(contact);

            Assert.Null(dto);
        }
コード例 #14
0
ファイル: HomeController.cs プロジェクト: Laila32496/Amourss
 public ActionResult AddContact(Contact contact)
 {
     if (ContactRepo.Insert(contact))
     {
         Notify("Success", "Successfully Savd", "your message has been successfully saved", false, false, true);
     }
     else
     {
         Notify("Error", "Technical Error", "Unable to save message due to technical error", false, false, true);
     }
     return(RedirectToAction("Contact"));
 }
コード例 #15
0
        public void EditContact_FirstAndLastIsNullOrWhiteSpace()
        {
            var id      = 1;
            var repo    = new ContactRepo(null);
            var contact = new Contact()
            {
                Id = id, FirstName = null, LastName = null
            };

            var result = repo.EditContact(id, contact);

            Assert.False(result);
        }
コード例 #16
0
        public void EditContact_IdsNotMatching()
        {
            int id = 1, id2 = 2;
            var repo    = new ContactRepo(null);
            var contact = new Contact()
            {
                Id = id, FirstName = "Kevin", LastName = null
            };

            var result = repo.EditContact(id2, contact);

            Assert.False(result);
        }
コード例 #17
0
        public ActionResult Details(int id)
        {
            if (id == 0)
            {
                throw new ArgumentException("參數錯誤");
            }
            var data = ContactRepo.Find(id);

            if (data == null)
            {
                throw new InvalidOperationException("操作錯誤");
            }
            return(View(data));
        }
コード例 #18
0
 public ActionResult DeleteContact(int id)
 {
     try
     {
         ContactRepo ContactRepoObj = new ContactRepo();
         if (ContactRepoObj.DeleteContact(id))
         {
             ViewBag.AlertMsg = "Employee details deleted successfully";
         }
         return(RedirectToAction("GetAllContactDetails"));
     }
     catch
     {
         return(RedirectToAction("GetAllContactDetails"));
     }
 }
コード例 #19
0
 protected void btnRemove_Click(object sender, EventArgs e)
 {
     try
     {
         LinkButton lnk = (LinkButton)sender;
         int        Id  = ToSQL.SQLToInt(lnk.CommandArgument);
         if (Id > 0)
         {
             int i = new ContactRepo().DeleteContact(Id);
             BindItemsList();
         }
     }
     catch
     {
     }
 }
コード例 #20
0
        public async Task <ActionResult> GetContacts(string AccountName, string ConatctName)
        {
            try
            {
                List <ContactModel> list        = new List <ContactModel>();
                ContactRepo         contactRepo = new ContactRepo();
                list = await contactRepo.GetAccounts(AccountName, ConatctName);

                //return new JsonResult() { Data = list, MaxJsonLength = 86753090, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #21
0
ファイル: ContactLogic.cs プロジェクト: yashika9/ContactUs
        public async Task <string> SaveContacts(Contact contact)
        {
            ContactRepo contactRepo = new ContactRepo();

            try
            {
                if (contact != null)
                {
                    return(await contactRepo.SaveContact(contact));
                }
            }
            catch (Exception)
            {
                throw new Exception("Cannot save empty contact!");
            }
            return("");
        }
コード例 #22
0
ファイル: Contact.aspx.cs プロジェクト: htphongqn/B2C_EC
        protected void btnContact_Click(object sender, EventArgs e)
        {
            Model.Contact contact = new Model.Contact();
            contact.FirstName   = txtFirstName.Text;
            contact.LastName    = txtLastName.Text;
            contact.Email       = txtEmail.Text;
            contact.Comment     = txtComments.Text;
            contact.DateCreated = DateTime.Now;
            int i = new ContactRepo().CreateContact(contact);

            txtFirstName.Text = "";
            txtLastName.Text  = "";
            txtEmail.Text     = "";
            txtComments.Text  = "";
            lbMessage.Text    = "Sent contact successfully!";
            Response.Redirect("Contact.aspx");
        }
        public static Trawick.Common.Email.EmailResponse SendCancelEnrollmentCancellationRequest(Trawick.Data.Models.EnrollmentCancellationRequest request)
        {
            string toEmail = "*****@*****.**";
            string subject = "Enrollment Cancellation Request";
            string message = string.Format("Please <strong> DO NOT </strong> Cancel Enrollment {0} on the Following Date: {1}", request.MasterEnrollmentId, request.RequestDate.ToShortDateString());

            string header = "<h2>{0}</h2> ";

            string body = "";

            body += string.Format(header, message);
            body += "<br/>";
            body += request.RequestMessage;
            string title = string.Format("<h5>{0}</h5>", subject);

            message = body;

            string ccEmail = "";

            if (request.CopyAgent)
            {
                var agent = ContactRepo.Contact_GetById(request.AgentId);
                if (agent != null && !string.IsNullOrEmpty(agent.admin_email))
                {
                    ccEmail = agent.admin_email;
                }
            }

            var args = new Common.Email.EmailArgs()
            {
                EmailBody    = message,
                EmaillCC     = ccEmail,
                EmailTo      = toEmail,
                EmailSubject = subject,
                IsHtml       = true
            };

            var response = new Trawick.Common.Email.EmailResponse()
            {
            };

            response = Trawick.Common.Email.EmailFactory.GetEmailFactory().SendMail(args);
            return(response);
        }
コード例 #24
0
ファイル: ContactRepoTests.cs プロジェクト: sozoev/PhoneBook
        public void Init()
        {
            var contacts = new ObservableCollection <Contact>(new[]
            {
                new Contact
                {
                    Id           = 1,
                    Name         = "Иванов Иван Иванович",
                    Email        = "*****@*****.**",
                    Organization = "MacroSoft LTD",
                    PhoneNumbers = new List <PhoneNumber>(new[]
                    {
                        new PhoneNumber
                        {
                            Number = "+996 799 699119",
                            Type   = "work"
                        }
                    })
                },
                new Contact
                {
                    Id           = 2,
                    Name         = "Петров Петр Алесеевич",
                    Email        = "*****@*****.**",
                    Organization = "SoftTechical Company LTD",
                    PhoneNumbers = new List <PhoneNumber>(new[]
                    {
                        new PhoneNumber
                        {
                            Number = "+996 998 699009",
                            Type   = "home"
                        }
                    })
                }
            });

            var mock = new Mock <PhoneBookDbContext>();

            mock.Setup(ctx => ctx.Contacts)
            .ReturnsDbSet(new FakeDbSet <Contact>(contacts));

            _subject = new ContactRepo(mock.Object);
        }
コード例 #25
0
        public ActionResult BatchSaveContact(List <BatchContacts> model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ContactRepo.BatchUpdate(model);
                    ContactRepo.UnitOfWork.Commit();
                    return(Json(new { isValid = true, message = HttpUtility.HtmlEncode("客戶聯絡人資料更新成功") }));
                }
                catch (Exception ex)
                {
                    return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存失敗。錯誤訊息: " + ex.Message) }));
                }
            }
            var msg = string.Join(" ", ModelState.Values.SelectMany(p => p.Errors).Select(p => p.ErrorMessage));

            return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存時,驗證欄位失敗。" + msg) }));
        }
コード例 #26
0
        public ActionResult UpdateContact(ContactModel ContactModelObj)
        {
            ContactRepo ContactRepoObj = new ContactRepo();

            try
            {
                if (ModelState.IsValid)
                {
                    if (ContactRepoObj.UpdateContact(ContactModelObj))
                    {
                        ViewBag.Message = "Contact details updated successfully";
                    }
                }
                return(RedirectToAction("GetAllContactDetails"));
            }
            catch
            {
                return(RedirectToAction("GetAllContactDetails"));
            }
        }
コード例 #27
0
        public ActionResult Save(客戶聯絡人 model)
        {
            var msg = "客戶聯絡人" + (model.Id == 0 ? "新增" : "更新") + "成功";

            if (ModelState.IsValid)
            {
                try
                {
                    ContactRepo.Save(model);
                    ContactRepo.UnitOfWork.Commit();
                    return(Json(new { id = model.Id, isValid = true, message = HttpUtility.HtmlEncode(msg) }));
                }
                catch (Exception ex)
                {
                    return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存失敗。錯誤訊息: " + ex.Message) }));
                }
            }
            msg = string.Join(" ", ModelState.Values.SelectMany(p => p.Errors).Select(p => p.ErrorMessage));
            return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存時,驗證欄位失敗。" + msg) }));
        }
コード例 #28
0
        private void AddContact(ContactRepo repository, int logUserId)
        {
            Console.WriteLine("#########################");
            Contact contact = new Contact();

            contact.ParentUserId = logUserId;
            Console.WriteLine("#### FirstName: ");
            contact.FirstName = Console.ReadLine();
            Console.WriteLine("#### LastName: ");
            contact.LastName = Console.ReadLine();
            Console.WriteLine("#### Email: ");
            contact.Email = Console.ReadLine();
            Console.WriteLine("#### Phone: ");
            contact.Phone = Console.ReadLine();
            repository.Add(contact);
            Console.Clear();
            Console.WriteLine("#########################");
            Console.WriteLine("####### D O N E ! #######");
            Console.WriteLine("#########################");
            Thread.Sleep(1000);
        }
コード例 #29
0
        public ActionResult Delete(int id)
        {
            var data   = ContactRepo.Find(id);
            var DelMsg = "客戶聯絡人不存在。";

            if (data != null)
            {
                try
                {
                    ContactRepo.Delete(data);
                    ContactRepo.UnitOfWork.Commit();
                    DelMsg = "客戶聯絡人刪除成功。";
                }
                catch (Exception ex)
                {
                    DelMsg = "客戶聯絡人刪除失敗。錯誤訊息: " + ex.Message;
                }
            }
            TempData["DelMsg"] = DelMsg;
            return(RedirectToAction("Index"));
        }
コード例 #30
0
        private void EditContact(ContactRepo repository, List <Contact> contacts, int editId)
        {
            Console.WriteLine("#######################################");
            Console.WriteLine("###### Edit contact with id {0} ######", editId);
            Contact editedContact = new Contact();

            foreach (var contact in contacts)
            {
                if (contact.Id == editId)
                {
                    editedContact.ParentUserId = contact.ParentUserId;
                    Console.Clear();
                    Console.Write("#### Old First Name : ");
                    Console.WriteLine(contact.FirstName);
                    Console.Write("#### New First Name : ");
                    editedContact.FirstName = Console.ReadLine();
                    Console.Clear();
                    Console.Write("#### Old Last Name : ");
                    Console.WriteLine(contact.LastName);
                    Console.Write("#### New Last Name : ");
                    editedContact.LastName = Console.ReadLine();
                    Console.Clear();
                    Console.Write("#### Old Email : ");
                    Console.WriteLine(contact.Email);
                    Console.Write("#### New Email : ");
                    editedContact.Email = Console.ReadLine();
                    Console.Write("#### Old Phone : ");
                    Console.WriteLine(contact.Phone);
                    Console.Write("#### New Phone : ");
                    editedContact.Phone = Console.ReadLine();
                    repository.Edit(editId, editedContact);
                    Console.Clear();
                    Console.WriteLine("#########################");
                    Console.WriteLine("####### D O N E ! #######");
                    Console.WriteLine("#########################");
                    Thread.Sleep(1000);
                }
            }
        }