Exemple #1
0
        public ActionResult ManageRoles_Update([DataSourceRequest] DataSourceRequest request, PersonRolesMapping _objPersonRoles)
        {
            if (ModelState.IsValid)
            {
                _objPersonRoles.UpdatedBy   = CurrentUser.NameIdentifierInt64;
                _objPersonRoles.UpdatedDate = DateTime.Now;
                var person = _PersonBAL.Person_GetAllByIdBAL(Convert.ToString(_objPersonRoles.PersonID));

                if (_objPersonRoles.IsLogin == true && _objPersonRoles.Password != null)
                {
                    if (_UserBAL.LoginUsers_DuplicationCheckBAL(new LoginUsers {
                        Email = person.Email
                    }) > 0)
                    {
                        ModelState.AddModelError(lr.UsersTitle, lr.UserEmailAlreadyExist);
                        if (_PersonBAL.TMS_PersonRolesMapping_DuplicationCheckBAL(_objPersonRoles) > 0)
                        {
                            ModelState.AddModelError(lr.VenueName, lr.VenueDuplicationCheck);
                        }
                        else
                        {
                            var    result = _PersonBAL.TMS_PersonRolesMapping_UpdateBAL(_objPersonRoles);
                            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.Update, System.Web.HttpContext.Current.Request.Browser.Browser);

                            if (result == -1)
                            {
                                ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                            }
                        }
                    }
                    else
                    {
                        _objPersonRoles.Password = Crypto.CreatePasswordHash(_objPersonRoles.Password);
                        _PersonBAL.TMS_PersonintoUser_CreateBAL(_objPersonRoles);
                        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);

                        if (_PersonBAL.TMS_PersonRolesMapping_DuplicationCheckBAL(_objPersonRoles) > 0)
                        {
                            ModelState.AddModelError(lr.VenueName, lr.VenueDuplicationCheck);
                        }
                        else
                        {
                            var result = _PersonBAL.TMS_PersonRolesMapping_UpdateBAL(_objPersonRoles);
                            if (result == -1)
                            {
                                ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                            }
                        }
                    }
                }
                else
                {
                    if (_PersonBAL.TMS_PersonRolesMapping_DuplicationCheckBAL(_objPersonRoles) > 0)
                    {
                        ModelState.AddModelError(lr.VenueName, lr.VenueDuplicationCheck);
                    }
                    else
                    {
                        var result = _PersonBAL.TMS_PersonRolesMapping_UpdateBAL(_objPersonRoles);
                        if (result == -1)
                        {
                            ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                        }
                    }
                }
                //
                //if (_PersonBAL.TMS_PersonRolesMapping_DuplicationCheckBAL(_objPersonRoles) > 0)
                //{
                //    ModelState.AddModelError(lr.VenueName, lr.VenueDuplicationCheck);
                //}
                //else
                //{
                //    var result = _PersonBAL.TMS_PersonRolesMapping_UpdateBAL(_objPersonRoles);
                //    if (result == -1)
                //    {
                //        ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                //    }
                //}
            }
            var resultData = new[] { _objPersonRoles };

            return(Json(resultData.AsQueryable().ToDataSourceResult(request, ModelState)));
        }