예제 #1
0
        public async Task <List <ThongKeNhuanButByAuthor> > Detail(long authorId, string month)
        {
            var author = await _authorManager.Find_By_Id(authorId);

            var listContentByAuthor = await _thongKeNhuanButManager.Get_Content_By_Author_Month(authorId, month);

            var listType = await _thongKeNhuanButManager.Get_List_Type(month);

            var donGia     = (await _thongKeNhuanButManager.Get_Don_Gia(month)) == null ? 0 : (await _thongKeNhuanButManager.Get_Don_Gia(month)).Value;
            var listResult = new List <ThongKeNhuanButByAuthor>();

            foreach (var item in listContentByAuthor)
            {
                var loaiBv = listType.Where(c => c.TypeId == Convert.ToInt64(item.ContentType.Value)).Select(c => new TheLoai_HeSo {
                    TypeName = c.TypeName, Coefficient = c.Coefficient
                }).FirstOrDefault();
                ThongKeNhuanButByAuthor model = new ThongKeNhuanButByAuthor()
                {
                    ContentName = item.Title,
                    Dongia      = (long)donGia,
                    LoaiBaiViet = loaiBv == null ? "" : loaiBv.TypeName,
                    HeSo        = loaiBv == null ? 0 : loaiBv.Coefficient,
                    Thang       = month,
                    TacGia      = author == null ? "" : author.Name,
                };
                listResult.Add(model);
            }
            foreach (var item in listResult)
            {
                item.Tongtien = (decimal)(item.HeSo * item.Dongia);
                item.NhuanBut = item.Tongtien * 40 / 100;
            }
            listResult = listResult.OrderBy(c => c.LoaiBaiViet).ToList();
            return(listResult);
        }
예제 #2
0
        public async Task <IActionResult> Update([FromBody] Authors inputModel)
        {
            try
            {
                var data = await _authorManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception(MessageConst.DATA_NOT_FOUND);
                }
                inputModel.CreatedDate = data.CreatedDate;
                inputModel.UpdatedDate = DateTime.Now;
                await _authorManager.Update(inputModel);

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