Ejemplo n.º 1
0
        private async Task <BorrowCommonViewModel> GetBorrowCommonModelAsync(int?id)
        {
            BorrowCommonViewModel common = new BorrowCommonViewModel();

            common.Borrow = await this.GetBorrowModelAsync(id);

            return(common);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind] BorrowCommonViewModel common)
        {
            if (id != common.Borrow.BorrowId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await this._borrowService.ChangeDuration(common.Borrow.BorrowId, common.Borrow.Start, common.Borrow.End);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(common.Borrow));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Score(int id, [Bind] BorrowCommonViewModel common)
        {
            if (id != common.Borrow.BorrowId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await this._borrowService.SetScore(common.Borrow.BorrowId, User, common.Borrow.Score);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(common.Borrow));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind] BorrowCommonViewModel common)
        {
            if (ModelState.IsValid)
            {
                await this._borrowService.Create(User, common.Borrow);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ViewData["idProduct"]    = common.Borrow.ProductId;
                ViewData["productStart"] = common.Borrow.ProductStart;
                ViewData["productEnd"]   = common.Borrow.ProductEnd;
            }
            return(View(common.Borrow));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> AddComment(int id, [Bind] BorrowCommonViewModel common)
        {
            if (id != common.Borrow.BorrowId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await this._borrowService.AddComment(common.Borrow.BorrowId, common.Comment.Text, User);

                common = await this.GetBorrowCommonModelAsync(id);

                return(View(common));
            }
            return(View(common));
        }