当前位置: 首页>>代码示例>>C#>>正文


C# Response.AddMessage方法代码示例

本文整理汇总了C#中Response.AddMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Response.AddMessage方法的具体用法?C# Response.AddMessage怎么用?C# Response.AddMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response.AddMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateUserAsync

 public static async Task<Response> CreateUserAsync(AddUserModel registerModel)
 {
     var response = new Response();
     var context = new AdminDbContext();
     ValidateUser(registerModel, response);
     if (!response.Success)
     {
         return response;
     }
     if (context.Users.Any(u => u.Email.Equals(registerModel.Email)))
     {
         response.AddMessage(false, "This email is already registered", ResponseMessageType.Warning);
     }
     else
     {
         var user = new User();
         user.Email = registerModel.Email;
         user.Password = GenerateHashWithSalt(registerModel.Password, registerModel.Email);
         user.PasswordSalt = Path.GetRandomFileName();
         user.RegisterDate = registerModel.RegisterDate;
         user.Active = registerModel.Active;
         context.Users.Add(user);
         await context.SaveChangesAsync();
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:26,代码来源:UserManager.cs

示例2: AddRelationTypeAsync

        public static async Task<Utils.Messages.Response> AddRelationTypeAsync(RelationTypeAddEditModel relationTypeModel)
        {

            var response = new Response();
            var context = new AdminDbContext();
            if (context.RelationTypes.Any(u => u.Code.Equals(relationTypeModel.Code)))
            {
                response.AddMessage(false, "This code is already registered", ResponseMessageType.Warning);
            }
            else
            {
                var relationType = new RelationType();
                relationType.Code = relationTypeModel.Code;
                relationType.Name = relationTypeModel.Name;
                context.RelationTypes.Add(relationType);
                await context.SaveChangesAsync();
            }
            return response;
        }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:19,代码来源:RelationTypeManager.cs

示例3: Create

 public static Response Create(RegisterModel registerModel)
 {
     var response = new Response();
     var context = new AdminDbContext();
     if (context.Users.Any(u => u.Email.Equals(registerModel.Email)))
     {
         response.AddMessage(false, "This email is already registered", ResponseMessageType.Warning);
     }
     else
     {
         var user = new User();
         user.Email = registerModel.Email;
         user.Password = GenerateHashWithSalt(registerModel.Password, registerModel.Email);
         user.PasswordSalt = Path.GetRandomFileName();
         context.Users.Add(user);
         context.SaveChanges();
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:19,代码来源:UserManager.cs

示例4: ValidateRelation

 public static Response ValidateRelation(RelationAddEditModel relation, Response response = null)
 {
     response = response ?? new Response();
     
     if (relation.TypeId == 0)
     {
         response.AddMessage(false, "Select a Relation Type", ResponseMessageType.Warning);
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:10,代码来源:RelationManager.cs

示例5: EditEntiTypeAsync

        public static async Task<Utils.Messages.Response> EditEntiTypeAsync(EntityTypeAddEditModel entityTypeModel)
        {

            var response = new Response();
            var context = new AdminDbContext();
            if (context.EntityTypes.Any(u => u.Code.Equals(entityTypeModel.Code)&&!u.Id.Equals(entityTypeModel.Id)))
            {
                response.AddMessage(false, "This code is already registered on another entity", ResponseMessageType.Warning);
            }
            else
            {
                var entityType = context.EntityTypes.Find(entityTypeModel.Id);
                entityType.Code = entityTypeModel.Code;
                entityType.Name = entityTypeModel.Name;
                await context.SaveChangesAsync();
            }
            return response;
        }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:18,代码来源:EntityTypeManager.cs

示例6: ValidateEntityRelation

 private static Response ValidateEntityRelation(AddEntityRelationModel addEntityRelationModel, Response response = null)
 {
     response = response ?? new Response();
     if (addEntityRelationModel.Id == 0)
     {
         response.AddMessage(false, "Please select an entity", ResponseMessageType.Warning);
     }
     if (addEntityRelationModel.RelationTypeId == 0)
     {
         response.AddMessage(false, "Please select a relation type", ResponseMessageType.Warning);
     }
     if (addEntityRelationModel.OtherEntityId == 0)
     {
         response.AddMessage(false, "Please select the second entity", ResponseMessageType.Warning);
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:17,代码来源:EntityManager.cs

示例7: ValidateEntity

 public static Response ValidateEntity(EntityAddEditModel entity, Response response = null)
 {
     response = response ?? new Response();
     if (string.IsNullOrEmpty(entity.Name))
     {
         response.AddMessage(false, "The name should not be empty", ResponseMessageType.Warning);
     }
     if (entity.TypeId == 0)
     {
         response.AddMessage(false, "Select an Entity Type", ResponseMessageType.Warning);
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:13,代码来源:EntityManager.cs

示例8: GetUser

 public static Response GetUser(string username, string password)
 {
     var response = new Response();
     var context = new AdminDbContext();
     var hashedPassword = GenerateHashWithSalt(password, username);
     var user = context.Users.FirstOrDefault(u => u.Email.Equals(username) && u.Password.Equals(hashedPassword));
     if (user != null)
     {
         response.Data = user;
     }
     else
     {
         response.AddMessage(false, "Username or password is invalid", ResponseMessageType.Warning);
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:16,代码来源:UserManager.cs

示例9: ValidateUser

 public static Response ValidateUser(AddUserModel registerModel, Response response = null)
 {
     response = response ?? new Response();
     if (string.IsNullOrEmpty(registerModel.Email))
     {
         response.AddMessage(false, "Email is mandatory", ResponseMessageType.Warning);
     }
     if (registerModel.Id == 0)
     {
         if (string.IsNullOrEmpty(registerModel.Password))
         {
             response.AddMessage(false, "Password is mandatory", ResponseMessageType.Warning);
         }
     }
     return response;
 }
开发者ID:occrp,项目名称:public-person-profiler,代码行数:16,代码来源:UserManager.cs


注:本文中的Response.AddMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。