Beispiel #1
0
        public bool AddUser(int Id, string FIO, string position)
        {
            if (FIO == "" || position == "")
            {
                return(false);
            }
            else
            {
                switch (position)
                {
                case "admin":
                    adminin tmp = new adminin();
                    tmp.FIO     = FIO;
                    tmp.adminId = Id;
                    AdmininRepository _ad = new AdmininRepository();
                    if (_ad.GetObject(Id) != null)
                    {
                        return(false);
                    }
                    else
                    {
                        _ad.Create(tmp); _ad.Save(); return(true);
                    }

                case "employer":
                    EmployeeRepository _em  = new EmployeeRepository();
                    employee           tmp1 = new employee();
                    tmp1.FIO    = FIO;
                    tmp1.emplId = Id;
                    if (_em.GetObject(Id) != null)
                    {
                        return(false);
                    }
                    else
                    {
                        _em.Create(tmp1); _em.Save(); return(true);
                    }

                case "manager":
                    ManagerRepository _me  = new ManagerRepository();
                    manager           tmp2 = new manager();
                    tmp2.FIO       = FIO;
                    tmp2.managerId = Id;
                    if (_me.GetObject(Id) != null)
                    {
                        return(false);
                    }
                    else
                    {
                        _me.Create(tmp2); _me.Save(); return(true);
                    }

                default:
                    return(false);
                }
            }
        }
Beispiel #2
0
        public void MakeManager(ManagerDTO managerDTO)
        {
            if (managerDTO != null)
            {
                var     config = new MapperConfiguration(cfg => cfg.CreateMap <ManagerDTO, Manager>());
                IMapper mapper = config.CreateMapper();

                _managerRepository.Create(mapper.Map <ManagerDTO, Manager>(managerDTO));
                _managerRepository.Save();
            }
        }
Beispiel #3
0
        public async Task <IHttpActionResult> Create(ManagerAddDto managerAddDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (managerAddDto.UserAddDto == null)
            {
                return(BadRequest("User can not be null"));
            }
            managerRepository.Create(managerAddDto.ManagerAddDtoToManager());
            await db.SaveChangesAsync();

            return(Ok());
        }
 // POST: api/Manager
 public void Post(Manager manager)
 {
     ManagerRepository.Create(manager);
 }
Beispiel #5
0
 public Manager Create(Manager entity)
 {
     Validate(entity);
     return(_managerRepository.Create(entity));
 }