Exemplo n.º 1
0
        public IActionResult Put([FromQuery] string oldBinusianId, [FromBody] UserHeader value)
        {
            try
            {
                string href = DTOHelper.GetHref(Request);

                var q = db.UserHeader.Where(x => x.BinusianId == oldBinusianId).FirstOrDefault();
                q.BinusianId   = value.BinusianId;
                q.Email        = value.Email;
                q.Name         = value.Name;
                q.Position     = value.Position;
                q.Department   = value.Department;
                q.BusinessUnit = value.BusinessUnit;
                q.Extension    = value.Extension;
                q.Handphone    = value.Handphone;
                q.JobBand      = value.JobBand;
                q.LeadId       = value.LeadId;
                q.Role         = value.Role;

                db.SaveChanges();

                var q2 = new List <UserHeader>();
                q2.Add(q);

                q2 = FormatDisplay(q2, href);

                return(Ok(q2.FirstOrDefault()));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 2
0
        public IActionResult Filter([FromQuery] string keyword = "", [FromQuery] int page = 1, [FromQuery] int pageCount = 20)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.UserHeader
                    .Where(x => x.BinusianId.Contains(keyword) ||
                           x.Email.Contains(keyword) ||
                           x.Name.Contains(keyword) ||
                           x.Position.Contains(keyword) ||
                           x.Department.Contains(keyword) ||
                           x.JobBand.Contains(keyword) ||
                           x.LeadId.Contains(keyword) ||
                           x.Role.ToString() == keyword
                           )
                    .ToList();

            var q2 = FormatDisplay(q, href);

            q2 = Paginate(page, pageCount, href, q2);

            if (q2 == null)
            {
                return(NotFound());
            }
            return(Ok(q2));
        }
Exemplo n.º 3
0
        public IActionResult Get(int page = 1, int pageCount = 20)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.UserHeader.ToList();

            var userHeaders = FormatDisplay(q, href);

            userHeaders = Paginate(page, pageCount, href, userHeaders);

            return(Ok(userHeaders));
        }
Exemplo n.º 4
0
        public IActionResult Get(int page = 1, int pageCount = 20)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.Proposal.ToList();

            var proposalDTOs = FormatDisplay(q, href);

            proposalDTOs = Paginate(page, pageCount, href, proposalDTOs);

            return(Ok(proposalDTOs));
        }
Exemplo n.º 5
0
 public IActionResult UpdateOrder(Guid id, int order)
 {
     try
     {
         string href = DTOHelper.GetHref(Request);
         var    q    = db.Proposal.Where(x => x.ProposalId == id).FirstOrDefault();
         q.Order = order;
         db.SaveChanges();
         return(Ok(q));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 6
0
        public IActionResult Get(string id)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.UserHeader
                    .Where(x => x.BinusianId == id)
                    .ToList();

            var q2 = FormatDisplay(q, href, true).FirstOrDefault();

            if (q2 == null)
            {
                return(NotFound());
            }
            return(Ok(q2));
        }
Exemplo n.º 7
0
        public IActionResult Get(Guid id)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.Proposal
                    .Where(x => x.ProposalId == id)
                    .ToList();

            var q2 = FormatDisplay(q, href, true).FirstOrDefault();

            if (q2 == null)
            {
                return(NotFound());
            }
            return(Ok(q2));
        }
Exemplo n.º 8
0
        public IActionResult Filter([FromQuery] int year, [FromQuery] int phase, [FromQuery] int page = 1, [FromQuery] int pageCount = 20)
        {
            string href = DTOHelper.GetHref(Request);

            var q = db.Proposal
                    .Where(x => x.SubmitDate.Year == year &&
                           x.Phase == phase)
                    .ToList();

            var q2 = FormatDisplay(q, href);

            q2 = Paginate(page, pageCount, href, q2);

            if (q2 == null)
            {
                return(NotFound());
            }
            return(Ok(q2));
        }