Ejemplo n.º 1
0
        public ActionResult SaveContact(ContactDetails objcont)
        {
            try
            {
                objcont.companyid = Convert.ToInt32(Request.Form["txtcompid"]);
                objcont.contactid = Convert.ToInt32(Request.Form["txtconid"]);
                if (objcont.contactid == 0)
                {
                    ObjectParameter objParam     = new ObjectParameter("NewContactID", typeof(int));
                    var             NewContactid = context.SpaddContactClient(objcont.contactfullname, objcont.titlestandard, objcont.contactphone, objcont.contactcellphone, objcont.contactemail, objcont.linkedinprofileurl, "", objcont.companyid, "", objcont.combinednotes, User.Identity.Name, objParam).FirstOrDefault();
                    context.SaveChanges();
                    objcont.contactid = Convert.ToInt32(NewContactid);
                }
                else
                {
                    context.SpupdateContactClient(objcont.contactfullname, objcont.titlestandard, objcont.contactphone, objcont.contactcellphone, objcont.contactemail, objcont.linkedinprofileurl, objcont.combinednotes, objcont.contactid, "");
                    context.SaveChanges();
                }
                var data = context.Spgetclientnote(objcont.contactid, User.Identity.Name);
                if (data.Count() == 0)
                {
                    context.SpInsertclientnote(objcont.contactid, User.Identity.Name, objcont.combinednotes);
                    context.SaveChanges();
                }
                else
                {
                    context.Spupdateclientnote(objcont.contactid, User.Identity.Name, objcont.combinednotes);
                    context.SaveChanges();
                }


                TempData["ConEmail"] = objcont.contactemail;
            }
            catch (Exception ex)
            {
                cm.ErrorExceptionLogingByService(ex.ToString(), "ProspectViewCompanyClient" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "SaveContact", "NA", "NA", "NA", "WEB");
            }


            return(RedirectToAction("Index", new { @Compid = @cm.Code_Encrypt(CryptorEngine.Encrypt(objcont.companyid.ToString())) }));
        }