public ActionResult EmailAddress_Create([DataSourceRequest] DataSourceRequest request, string pid, EmailAddresses _objEmailAddresses) { if (ModelState.IsValid) { if (_UserBAL.LoginPerson_DuplicationCheckBAL(new Person { Email = _objEmailAddresses.Email, CreatedBy = CurrentUser.NameIdentifierInt64 }) > 0) { ModelState.AddModelError(lr.UserEmailAlreadyExist, lr.UserEmailAlreadyExist); // return Json(lr.UserEmailAlreadyExist, JsonRequestBehavior.AllowGet); } else { _objEmailAddresses.CreatedBy = CurrentUser.NameIdentifierInt64; _objEmailAddresses.CreatedDate = DateTime.Now; if (_objPersonContactBAL.PersonEmailAddress_GetCountByPersonIDBAL(Convert.ToInt64(pid)) >= TMSHelper.GetPersonEmailLimit()) { ModelState.AddModelError(lr.PersonContactEmail, string.Format(lr.PersonContactEmailLimit, TMSHelper.GetPersonEmailLimit().ToString())); } else if (_objPersonContactBAL.PersonEmailAddress_DuplicationCheckBAL(_objEmailAddresses, Convert.ToInt64(pid)) > 0) { ModelState.AddModelError(lr.PersonContactEmail, lr.PersonContactEmailDuplicationCheck); } else { _objEmailAddresses.ID = _objPersonContactBAL.PersonEmailAddress_CreateBAL(_objEmailAddresses, Convert.ToInt64(pid)); } } } var resultData = new[] { _objEmailAddresses }; return(Json(resultData.ToDataSourceResult(request, ModelState))); }
public ActionResult Person_Create([DataSourceRequest] DataSourceRequest request, Person _person, long RoleID) { if (ModelState.IsValid) { bool _valid = false; if (_UserBAL.LoginPerson_DuplicationCheckBAL(new Person { Email = _person.Email }) > 0) { ModelState.AddModelError(lr.UserEmailAlreadyExist, lr.UserEmailAlreadyExist); // return Json(lr.UserEmailAlreadyExist, JsonRequestBehavior.AllowGet); } else { if (_person.Email != null)//when Email is Provided { _valid = true; } else if (_person.ContactNumber != null) //when Contact number is provided { if (_person.CountryCode == 0) //when country code is provided { ModelState.AddModelError(lr.PersonPhoneCountryCode, lr.PersonPhoneNumberProvideCountryocde); } else { _valid = true; } } else { ModelState.AddModelError(lr.PersonContactEmail, lr.PersonEmailorPhoneRequired); } if (_valid) { // _person.ProfilePicture = HandlePersonProfilePicture(filename, _person.ID, aid); _person.CreatedBy = CurrentUser.NameIdentifierInt64; _person.CreatedDate = DateTime.Now; _person.OrganizationID = CurrentUser.CompanyID; string _profilePict = string.Empty; if (_person.ClientType == 0) { _person.ClientType = ClientType.ClientType_Internal; } var Resp = SavePersonData(_person, ref _profilePict, RoleID); string ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(ip)) { ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } _objConfigurationBAL.Audit_CreateBAL(ip, DateTime.Now, CurrentUser.CompanyID, CurrentUser.NameIdentifierInt64, EventType.Create, System.Web.HttpContext.Current.Request.Browser.Browser); _person.AddedByAlias = CurrentUser.Name; _person.ID = Resp.ID; _person.PersonRegCode = Resp.PersonRegCode; _person.ProfilePicture = _profilePict; if (_person.ID != long.MinValue) { // _PersonBAL.ManageAssigned_CreateBAL(_person); if (_person.ContactNumber != null)//when ContactNumber is Provided { PhoneNumbers _objPhoneNumbers = new PhoneNumbers { ContactNumber = _person.ContactNumber, CountryCode = _person.CountryCode, IsPrimary = true, Extension = _person.Extension, CreatedBy = CurrentUser.NameIdentifierInt64, CreatedDate = DateTime.Now }; _person.PhoneID = _objPersonContactBAL.PersonPhoneNumbers_CreateBAL(_objPhoneNumbers, _person.ID); } if (_person.Email != null)//when Email is Provided { EmailAddresses _objEmailAddresses = new EmailAddresses { Email = _person.Email, IsPrimary = true, CreatedBy = CurrentUser.NameIdentifierInt64, CreatedDate = DateTime.Now }; _person.EmailID = _objPersonContactBAL.PersonEmailAddress_CreateBAL(_objEmailAddresses, _person.ID); } } } } } var resultData = new[] { _person }; return(Json(resultData.ToDataSourceResult(request, ModelState))); }
public ActionResult Person_Create([DataSourceRequest] DataSourceRequest request, Person _person) { if (ModelState.IsValid) { bool _valid = false; if (_UserBAL.LoginPerson_DuplicationCheckBAL(new Person { Email = _person.Email, CreatedBy = CurrentUser.CompanyID }) > 0) { ModelState.AddModelError(lr.UserEmailAlreadyExist, lr.UserEmailAlreadyExist); // return Json(lr.UserEmailAlreadyExist, JsonRequestBehavior.AllowGet); _valid = false; } else if (_UserBAL.LoginPerson_DuplicationPhoneNumberCheckBAL(new Person { ContactNumber = _person.ContactNumber, CreatedBy = CurrentUser.CompanyID }) > 0) { ModelState.AddModelError(lr.DubliocationHappen, lr.PersonContactPhoneDuplicationCheck); //return Json(lr.UserEmailAlreadyExist, JsonRequestBehavior.AllowGet); } else { //if (_person.Email != null)//when Email is Provided //{ // _valid = true; //} //else //if (_person.ContactNumber != null)//when Contact number is provided //{ // if (_person.CountryCode == 0)//when country code is provided // { // ModelState.AddModelError(lr.PersonPhoneCountryCode, lr.PersonPhoneNumberProvideCountryocde); // } // else // { // _valid = true; // } //} //else //{ // ModelState.AddModelError(lr.PersonContactEmail, lr.PersonEmailorPhoneRequired); //} _valid = true; if (_valid) { _person.CreatedBy = CurrentUser.NameIdentifierInt64; _person.CreatedDate = DateTime.Now; _person.OrganizationID = CurrentUser.CompanyID; string _profilePict = string.Empty; _person.DateOfBirth = DateTime.Now; var Resp = SavePersonData(_person, ref _profilePict); _person.AddedByAlias = CurrentUser.Name; _person.ID = Resp.ID; long val = Convert.ToInt64(_person.AssignedToString); if (val == 0 || val < 0) { _person.AssignedTo = CurrentUser.NameIdentifierInt64; } else { _person.AssignedTo = val; } _person.PersonRegCode = Resp.PersonRegCode; _person.ProfilePicture = _profilePict; long crmval = (long)_person.CrmClientType; if (_person.ID != long.MinValue) { _PersonBAL.ManageAssigned_CreateBAL(_person); Library.TMS.Notifications nof = new Library.TMS.Notifications(); nof.NotificationText = "Your have assigned a prospect"; nof.Organization_ID = CurrentUser.CompanyID; nof.ToUser = Convert.ToInt64(_person.AssignedTo); nof.FromUser = CurrentUser.NameIdentifierInt64; nof.ActionUrl = "Prospect/Detail?pid=" + _person.ID; nof.Event_ID = 2; nof.CreatedDate = DateTime.Now; BALNotification.create_NotificationsBAL(nof); var notificationHub = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); notificationHub.Clients.All.notify("added"); if (_person.ContactNumber != null)//when ContactNumber is Provided { PhoneNumbers _objPhoneNumbers = new PhoneNumbers { ContactNumber = _person.ContactNumber, CountryCode = _person.CountryCode, IsPrimary = true, Extension = _person.Extension, CreatedBy = CurrentUser.NameIdentifierInt64, CreatedDate = DateTime.Now }; _person.PhoneID = _objPersonContactBAL.PersonPhoneNumbers_CreateBAL(_objPhoneNumbers, _person.ID); } if (_person.Email != null)//when Email is Provided { EmailAddresses _objEmailAddresses = new EmailAddresses { Email = _person.Email, IsPrimary = true, CreatedBy = CurrentUser.NameIdentifierInt64, CreatedDate = DateTime.Now }; _person.EmailID = _objPersonContactBAL.PersonEmailAddress_CreateBAL(_objEmailAddresses, _person.ID); } } } } } var resultData = new[] { _person }; return(Json(resultData.ToDataSourceResult(request, ModelState))); }