Ejemplo n.º 1
0
        public ActionResult CreateFaktura(Faktura faktura)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.AddProfile <FakturaVMToFakturaBLLProfile>();
                    });
                    var        mapper     = new Mapper(config);
                    FakturaBLL fakturaBLL = mapper.DefaultContext.Mapper.Map <FakturaBLL>(faktura);

                    FakturaService service      = new FakturaService();
                    var            returnAnswer = service.CreateFaktura(fakturaBLL);
                    if (returnAnswer == "OK")
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(RedirectToAction("CreateFaktura"));
                    }
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            return(View(faktura));
        }
Ejemplo n.º 2
0
        public ActionResult ViewAllFakture()
        {
            if (User.Identity.GetUserName() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                FakturaService service      = new FakturaService();
                var            returnAnswer = service.GetAllFakture();

                var config = new MapperConfiguration(cfg =>
                {
                    cfg.AddProfile <FakturaBLLToVMProfile>();
                });
                var            mapper  = new Mapper(config);
                List <Faktura> fakture = mapper.DefaultContext.Mapper.Map <List <Faktura> >(returnAnswer);

                if (fakture == null)
                {
                    return(RedirectToAction("CreateFaktura", "Home"));
                }
                else
                {
                    return(View(fakture));
                }
            }
        }