Exemplo n.º 1
0
        public async Task <IActionResult> updateProfile([FromBody] HrEmployee hrEmployee)
        {
            _context.Update(hrEmployee);
            await _context.SaveChangesAsync();

            return(Ok(hrEmployee));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutDailypoGroupReport([FromRoute] string id, [FromBody] DailypoGroupReport dailypoGroupReport)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dailypoGroupReport.GroupCode)
            {
                return(BadRequest());
            }

            _context.Entry(dailypoGroupReport).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DailypoGroupReportExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutDailypoProductTeam([FromRoute] int id, [FromBody] DailypoProductTeam dailypoProductTeam)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dailypoProductTeam.GptId)
            {
                return(BadRequest());
            }

            _context.Entry(dailypoProductTeam).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DailypoProductTeamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutSaleproGoodPattn([FromRoute] int id, [FromBody] SaleproGoodPattn saleproGoodPattn)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != saleproGoodPattn.Id)
            {
                return(BadRequest());
            }

            var getGoodPattn = await _context.GetTransactionInv
                               .Where(w => w.GoodPattnCode == saleproGoodPattn.GoodPattnCode)
                               .GroupBy(g => new { g.GoodPattnName })
                               .Select(s => new { s.Key.GoodPattnName })
                               .ToListAsync();

            var getGoodClass = await _context.GetTransactionInv
                               .Where(w => w.GoodClassCode == saleproGoodPattn.GoodClassCode)
                               .GroupBy(g => new { g.GoodClassName })
                               .Select(s => new { s.Key.GoodClassName })
                               .ToListAsync();

            var getSubCodePro = await _context.CodePromotion
                                .Where(w => w.SubId == saleproGoodPattn.SubId)
                                .GroupBy(g => new { g.SubCodePro })
                                .Select(s => new { s.Key.SubCodePro })
                                .ToListAsync();

            saleproGoodPattn.GoodPattnName = getGoodPattn[0].GoodPattnName;
            saleproGoodPattn.GoodClassName = getGoodClass[0].GoodClassName;
            saleproGoodPattn.SubCodePro    = getSubCodePro[0].SubCodePro;

            _context.Entry(saleproGoodPattn).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SaleproGoodPattnExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutGoodCateCode([FromRoute] int id, [FromBody] GoodCateCode goodCateCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != goodCateCode.Id)
            {
                return(BadRequest());
            }

            var getProduct = await _context.GetTransactionInv
                             .Where(w => w.ProductCode == goodCateCode.GoodCatecode)
                             .GroupBy(g => new { g.Product })
                             .Select(s => new { s.Key.Product })
                             .ToListAsync();

            var getSubCodePro = await _context.CodePromotion
                                .Where(w => w.SubId == goodCateCode.SubId)
                                .GroupBy(g => new { g.SubCodePro })
                                .Select(s => new { s.Key.SubCodePro })
                                .ToListAsync();

            goodCateCode.GoodCateName = getProduct[0].Product;
            goodCateCode.SubCodePro   = getSubCodePro[0].SubCodePro;

            _context.Entry(goodCateCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GoodCateCodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutListProductPromotion([FromRoute] int id, [FromBody] ListProductPromotion listProductPromotion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != listProductPromotion.Id)
            {
                return(BadRequest());
            }

            var getCode = await _context.GetTransactionInv
                          .Where(w => w.GoodId == listProductPromotion.GoodId)
                          .GroupBy(g => new { g.GoodCode })
                          .Select(s => new { s.Key.GoodCode })
                          .ToListAsync();

            var getSubCodePro = await _context.CodePromotion
                                .Where(w => w.SubId == listProductPromotion.SubId)
                                .GroupBy(g => new { g.SubCodePro })
                                .Select(s => new { s.Key.SubCodePro })
                                .ToListAsync();

            listProductPromotion.GoodCode   = getCode[0].GoodCode;
            listProductPromotion.SubCodePro = getSubCodePro[0].SubCodePro;

            _context.Entry(listProductPromotion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListProductPromotionExists(id.ToString()))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 7
0
        public IActionResult Put([FromBody] Balance value)
        {
            try
            {
                var Exists = value.BalancesHD.Where(x => x.BHDID > 0).ToList();
                if (Exists.Any())
                {
                    Exists.ForEach(o =>
                    {
                        var hd              = ctx.SaleProBalanceHDs.First(x => x.BHDID == o.BHDID);
                        hd.IsConfirm        = o.IsConfirm;
                        hd.CustCode         = o.CustCode;
                        hd.CustName         = o.CustName;
                        hd.EmpCode          = o.EmpCode;
                        hd.EmpName          = o.EmpName;
                        hd.GoodQty2         = o.GoodQty2;
                        hd.GoodAmnt         = o.GoodAmnt;
                        hd.TotalReward      = o.TotalReward;
                        hd.TotalGiftVoucher = o.TotalGiftVoucher;
                        hd.TotalDiscount    = o.TotalDiscount;
                        hd.TotalBonus       = o.TotalBonus;
                        ctx.SaveChanges();

                        o.BalancesDT.ToList().ForEach(p =>
                        {
                            var dt            = ctx.SaleProBalanceDTs.First(x => x.BDTID == p.BDTID);
                            dt.Target         = p.Target;
                            dt.Reward         = p.Reward;
                            dt.GiftVoucher    = p.GiftVoucher;
                            dt.Discount       = p.Discount;
                            dt.Bonus          = p.Bonus;
                            dt.IsBonus        = p.IsBonus;
                            dt.Unit           = p.Unit;
                            dt.RewardSelect   = p.RewardSelect;
                            dt.GiftSelect     = p.GiftSelect;
                            dt.DiscountSelect = p.DiscountSelect;
                            dt.BonusSelect    = p.BonusSelect;

                            ctx.SaveChanges();
                        });
                    });
                }

                var NotExists = value.BalancesHD.Where(x => x.BHDID == 0);
                if (NotExists.Any())
                {
                    ctx.AddRangeAsync(NotExists);
                    ctx.SaveChangesAsync();
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }