예제 #1
0
        public bool AddIntern(InternRequest requestIntern)
        {
            this.internRepository.Create(new Interns()
            {
                Name = requestIntern.Name, EmailId = requestIntern.EmailId, PhoneNo = requestIntern.PhoneNo, CreatedDate = DateTime.Now
            });

            this.internRepository.Save();

            return(true);
        }
예제 #2
0
        public bool UpdateIntern(int id, InternRequest internRequest)
        {
            if (id == internRequest.Id)
            {
                Interns intern = new Interns()
                {
                    InternsId   = id,
                    Name        = internRequest.Name,
                    EmailId     = internRequest.EmailId,
                    PhoneNo     = internRequest.PhoneNo,
                    CreatedDate = internRequest.CreatedDate
                };

                this.internRepository.Update(intern);
                this.internRepository.Save();

                return(true);
            }

            return(false);
        }
예제 #3
0
        public IActionResult Put(int id, [FromBody] InternRequest requestIntern)
        {
            try
            {
                var response = internService.UpdateIntern(id, requestIntern);

                if (response == true)
                {
                    return(Ok(response));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);

                throw;
            }
        }
예제 #4
0
        public IActionResult Post(InternRequest requestIntern)
        {
            try
            {
                var response = internService.AddIntern(requestIntern);

                if (response == true)
                {
                    return(Ok(response));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);

                throw;
            }
        }