public ActionResult CredentialAddNewPartial( [ModelBinder(typeof(DevExpressEditorsBinder))] SecurityCredentialModel item, Guid objectId) { if (ModelState.IsValid) { try { SecurityCredentialModel.CreateMap(); using (DBEntities context = Settings.CreateDataContext()) { SecurityCredential obj = Mapper.Map <SecurityCredentialModel, SecurityCredential>(item); obj.Id = Guid.NewGuid(); obj.SecurityUserId = objectId; obj.PasswordSalt = HashHelper.GenerateSalt(); if (obj.AuthenticationType == (byte)AuthenticationType.Generic && !string.IsNullOrEmpty(item.Password)) { obj.PasswordHash = HashHelper.GenerateStringHash(item.Password, obj.PasswordSalt); } context.AddToSecurityCredential(obj); context.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Пожалуйста, исправте все ошибки."; } return(CredentialPartial(objectId)); }