Ejemplo n.º 1
0
        public static void Fill(Models.Person entity, ViewModels.ViewPersonDto viewperson)
        {
            entity.Id         = viewperson.Id;
            entity.DateCreate = viewperson.DateCreate;
            entity.SexId      = viewperson.SexId;
            entity.FirstName  = viewperson.FirstName;
            entity.LastName   = viewperson.LastName;
            entity.DateBirth  = viewperson.DateBirth;
            entity.Email      = viewperson.Email;
            entity.Mobile     = viewperson.Mobile;
            entity.Address    = viewperson.Address;
            entity.IsActive   = viewperson.IsActive;
            entity.IsDeleted  = viewperson.IsDeleted;
            entity.Remark     = viewperson.Remark;
            entity.Nickname   = viewperson.Nickname;
            entity.IDNo       = viewperson.IDNo;
            entity.UserId     = viewperson.UserId;
            entity.ImageUrl   = viewperson.ImageUrl;
            entity.CountryId  = viewperson.CountryId;
            entity.ZIPCode    = viewperson.ZIPCode;
            entity.State      = viewperson.State;
            entity.City       = viewperson.City;
            entity.Company    = viewperson.Company;
            entity.University = viewperson.University;
            entity.Website    = viewperson.Website;
            entity.Twitter    = viewperson.Twitter;
            entity.LinkedIn   = viewperson.LinkedIn;
            entity.Headline   = viewperson.Headline;
            entity.DegreeId   = viewperson.DegreeId;
            entity.PositionId = viewperson.PositionId;
            entity.DateJoin   = viewperson.DateJoin;

            entity.FieldOfStudyId = viewperson.FieldOfStudyId;
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PostUser(ViewModels.ViewPersonDto dto)
        {
            // return Ok(client);
            if (dto == null)
            {
                return(Exceptions.getNullException(ModelState));
            }
            if (!ModelState.IsValid)
            {
                // return BadRequest(ModelState);
                return(Exceptions.getModelValidationException(ModelState));
            }
            var validate = unitOfWork.PersonRepository.Validate(dto);

            if (validate.Code != HttpStatusCode.OK)
            {
                return(validate);
            }

            Person entity = null;

            if (dto.Id == -1)
            {
                entity = new Person();
                unitOfWork.PersonRepository.Insert(entity);
            }

            else
            {
                entity = await unitOfWork.PersonRepository.GetByID(dto.Id);
            }

            if (entity == null)
            {
                return(Exceptions.getNotFoundException());
            }

            //ViewModels.Location.Fill(entity, dto);
            ViewModels.ViewPersonDto.Fill(entity, dto);



            var saveResult = await unitOfWork.SaveAsync();

            if (saveResult.Code != HttpStatusCode.OK)
            {
                return(saveResult);
            }

            dto.Id = entity.Id;
            var user = await unitOfWork.PersonRepository.GetViewPersonById(entity.Id);

            return(Ok(user));
        }
Ejemplo n.º 3
0
        public virtual CustomActionResult Validate(ViewModels.ViewPersonDto dto)
        {
            var c = this.context.ViewPersons.FirstOrDefault(q => q.Id != dto.Id && q.Email.ToLower() == dto.Email.ToLower());

            if (c != null)
            {
                return(new CustomActionResult(HttpStatusCode.NotAcceptable, "This email address is already being used."));
            }


            return(new CustomActionResult(HttpStatusCode.OK, ""));
        }
Ejemplo n.º 4
0
 public static void FillDto(Models.ViewPerson entity, ViewModels.ViewPersonDto viewperson)
 {
     viewperson.Id              = entity.Id;
     viewperson.DateCreate      = entity.DateCreate;
     viewperson.SexId           = entity.SexId;
     viewperson.FirstName       = entity.FirstName;
     viewperson.LastName        = entity.LastName;
     viewperson.DateBirth       = entity.DateBirth;
     viewperson.Email           = entity.Email;
     viewperson.Mobile          = entity.Mobile;
     viewperson.Address         = entity.Address;
     viewperson.IsActive        = entity.IsActive;
     viewperson.IsDeleted       = entity.IsDeleted;
     viewperson.Remark          = entity.Remark;
     viewperson.Nickname        = entity.Nickname;
     viewperson.IDNo            = entity.IDNo;
     viewperson.UserId          = entity.UserId;
     viewperson.ImageUrl        = entity.ImageUrl;
     viewperson.CountryId       = entity.CountryId;
     viewperson.ZIPCode         = entity.ZIPCode;
     viewperson.State           = entity.State;
     viewperson.City            = entity.City;
     viewperson.Company         = entity.Company;
     viewperson.University      = entity.University;
     viewperson.Website         = entity.Website;
     viewperson.Twitter         = entity.Twitter;
     viewperson.LinkedIn        = entity.LinkedIn;
     viewperson.Headline        = entity.Headline;
     viewperson.DegreeId        = entity.DegreeId;
     viewperson.PositionId      = entity.PositionId;
     viewperson.DateJoin        = entity.DateJoin;
     viewperson.DateJoinStr     = entity.DateJoinStr;
     viewperson.Name            = entity.Name;
     viewperson.FieldOfStudyId  = entity.FieldOfStudyId;
     viewperson.Position        = entity.Position;
     viewperson.FieldOfStudy    = entity.FieldOfStudy;
     viewperson.Degree          = entity.Degree;
     viewperson.CountrySortName = entity.CountrySortName;
     viewperson.Country         = entity.Country;
     viewperson.Location        = entity.Location;
     viewperson.Education       = entity.Education;
 }