Example #1
0
        //Raskid Ugovora
        public ActionResult Raskid(int vozacID)
        {
            RaskidVM Model = ctx.Vozaci.Where(x => x.ZaposlenikId == vozacID)
                             .Select(
                x => new RaskidVM
            {
                datumRaskida = DateTime.Now,
                vozacId      = x.ZaposlenikId,
                statusId     = x.StatusVozacaId
            }).FirstOrDefault();

            Model.statusi = getStatusi();

            Model.statusi.Where(x => x.Value == Model.statusId.ToString()).FirstOrDefault().Selected = true;

            return(PartialView("_Raskid", Model));
        }
Example #2
0
        public async Task <JsonResult> Raskid(RaskidVM vm)
        {
            Vozac vozac = await ctx.Vozaci.FindAsync(vm.vozacId);

            if (!ModelState.IsValid)
            {
                var errors = ViewData.ModelState.Where(n => n.Value.Errors.Count > 0).Select(x => new ErrorHelper()
                {
                    Message = x.Value.Errors.Select(y => y.ErrorMessage).FirstOrDefault(),
                    Name    = x.Key
                }
                                                                                             ).ToList();
                return(Json(new { Errors = errors }));
            }
            vozac.DatumOtkaza    = vm.datumRaskida;
            vozac.StatusVozacaId = vm.statusId;
            await ctx.SaveChangesAsync();

            return(Json(new { Url = "Detalji?vozacID=" + vozac.ZaposlenikId }));
        }