Пример #1
0
 public ActionResult SaveContactInfo(ContactModel data)
 {
     try
     {
         var user     = UserManager.FindById(User.Identity.GetUserId());
         var getQuery = "select ContactId from Contact where ContactId='" + User.Identity.GetUserId() + "'";
         var contact  = ClassDB.CheckRecord(getQuery);
         if (contact == null || contact == "")
         {
             var query = "insert into Contact (ContactId,FirstName,LastName,JobTitle,Department,MobilePhone,EMailAddress1) values('" + User.Identity.GetUserId() + "','" +
                         data.FirstName + "','" + data.LastName + "','" +
                         data.JobTitle + "','" + data.Department + "','" +
                         data.MobilePhone + "','" + data.EMailAddress1 + "') SELECT SCOPE_IDENTITY()";
             var result = ClassDB.Insert(query);
         }
         else
         {
             var query  = @"update Contact set FirstName = '" + data.FirstName + @"',
                             LastName = '" + data.LastName + @"',
                             JobTitle = '" + data.JobTitle + @"',
                             Department = '" + data.Department + @"',
                             MobilePhone = '" + data.MobilePhone + @"',
                             EMailAddress1 = '" + data.EMailAddress1 + "' where ContactId='" + User.Identity.GetUserId() + "'";
             var result = ClassDB.update(query);
         }
         user.UserProfileCompleted = true;
         UserManager.Update(user);
         return(RedirectToAction("AccountInfo", "Account"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public ActionResult SaveAccountInfo(AccountModel data)
 {
     try
     {
         var getQuery         = "select ParentCustomerId from Contact where ContactId='" + User.Identity.GetUserId() + "'";
         var ParentCustomerId = ClassDB.CheckRecord(getQuery);
         if (ParentCustomerId == null)
         {
             var query = "insert into Account (AccountID,EMailAddress1,Name,Telephone1,StateCode,OwnerId,OwnerIdType,LivestockType) OUTPUT INSERTED.AccountId values(NEWID()" + ",'" +
                         data.EMailAddress1 + "','" + data.Name + "','" + data.Telephone1 + "','0','" + User.Identity.GetUserId() + "','1','1') SELECT SCOPE_IDENTITY()";
             var result        = ClassDB.Insert(query);
             var updateContact = @"update Contact set ParentCustomerId = '" + result + "' where ContactId='" + User.Identity.GetUserId() + "'";
             var res           = ClassDB.update(updateContact);
         }
         else
         {
             var query = @"update Account set EMailAddress1 = '" + data.EMailAddress1 + @"',
                             Name = '" + data.Name + @"',
                             Telephone1 = '" + data.Telephone1
                         + "' where AccountId='" + ParentCustomerId + "'";
             var result = ClassDB.update(query);
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }