api updates

This commit is contained in:
henrydays 2018-08-28 02:44:36 +01:00
parent b7c2d96b9f
commit 227ff8cf93
7 changed files with 51 additions and 9 deletions

View File

@ -27,18 +27,39 @@ namespace api.Controllers
[HttpPost("register")]
public async Task<IActionResult> Register(UserForRegisterDto UserForRegisterDto)
{
//validar a request
UserForRegisterDto.Username = UserForRegisterDto.Username.ToLower();
if (await repo.UserExists(UserForRegisterDto.Username))
UserForRegisterDto.username = UserForRegisterDto.username.ToLower();
//validar a request
if (await repo.UserExists(UserForRegisterDto.username))
return BadRequest("username already exists");
var userToCreate = new User
{
username = UserForRegisterDto.Username
username = UserForRegisterDto.username,
fullname = UserForRegisterDto.fullname,
gender= UserForRegisterDto.gender,
age= UserForRegisterDto.age,
phone= UserForRegisterDto.phone,
email=UserForRegisterDto.email,
adress=UserForRegisterDto.adress,
country=UserForRegisterDto.country,
city=UserForRegisterDto.city,
linkedin=UserForRegisterDto.linkedin,
lastlogin=UserForRegisterDto.lastlogin,
registed=UserForRegisterDto.registed,
qrcode=UserForRegisterDto.qrcode,
role=UserForRegisterDto.role,
degree=UserForRegisterDto.degree,
schoolyear=UserForRegisterDto.schoolyear,
profileicon=UserForRegisterDto.profileicon,
company=UserForRegisterDto.company,
position=UserForRegisterDto.position,
about=UserForRegisterDto.about
};
var createUser = await repo.Register(userToCreate, UserForRegisterDto.Password);
var createUser = await repo.Register(userToCreate, UserForRegisterDto.password);
return StatusCode(201);

View File

@ -1,3 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace api.Dtos
@ -5,11 +6,31 @@ namespace api.Dtos
public class UserForRegisterDto
{
[Required]
public string Username {get;set;}
public string username {get;set;}
[Required]
[StringLength(8,MinimumLength=4,ErrorMessage="You must specify password between 4 and 8 cars")]
public string Password{get;set;}
[StringLength(8,MinimumLength=4,ErrorMessage="You must specify password between 4 and 8 cars")]
public string password{get;set;}
public string fullname {get;set;}
public string gender {get;set;}
public int age{get;set;}
public int phone{get;set;}
public string email{get;set;}
public string university{get;set;}
public string adress{get;set;}
public string country{get;set;}
public string city{get;set;}
public string linkedin{get;set;}
public DateTime lastlogin {get;set;}
public DateTime registed{get;set;}
public string qrcode{get;set;}
public string role{get;set;}
public string degree{get;set;}
public int schoolyear{get;set;}
public string profileicon {get;set;}
public string company{get;set;}
public string position{get;set;}
public string about{get;set;}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.