示例#1
0
        private VMs.User ConvertVMUser(Data.User user)
        {
            VMs.User result = new VMs.User();

            try
            {
                result.Id       = user.Id;
                result.Name     = user.Name;
                result.Type     = user.Type.ToString();
                result.Login    = user.Login;
                result.Password = user.Password;
                result.Company  = user.Company;

                return(result);
            }
            catch (Exception ex) { throw ex; }
        }
示例#2
0
        public async Task <ActionResult <bool> > Save([FromBody] VMs.User user)
        {
            try
            {
                //Validation
                if (!context.Users
                    .Where(x => x.RowStatus == Base.enRowStatus.Active && x.Login == user.Login && x.Email == user.Email)
                    .Any())
                {
                    // USERS

                    var userId = context.Users
                                 .Max(x => x.Id);

                    var dataUser = new Data.User
                    {
                        Id        = ++userId,
                        Company   = user.Company,
                        Login     = user.Login,
                        Name      = user.Name,
                        Password  = user.Password,
                        Email     = user.Email,
                        TypeInner = (short)Enum.Parse(typeof(enUserType), user.Type),

                        RowStatus = Base.enRowStatus.Active,
                        RowDate   = DateTime.Now,
                    };

                    context.Users.Add(dataUser);

                    await context.SaveChangesAsync();

                    return(OkResponse(true));
                }
                else
                {
                    throw new Exception("Usuário já cadastrado!");
                }
            }
            catch (Exception ex) { return(BadRequestResponse(ex)); }
            finally { context.Dispose(); }
        }
示例#3
0
文件: Load.cs 项目: icrxz/SupportAPI
        public VMs.User ConvertVMUser(Data.User user)
        {
            try
            {
                VMs.User result = new VMs.User
                {
                    Id       = user.Id,
                    Name     = user.Name,
                    Company  = user.Company,
                    Login    = user.Login,
                    Password = user.Password,
                    Email    = user.Email,
                    Type     = user.Type.ToString()
                };

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }