Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "UserId,Nick,UserName,Password,Role,Company,Comment,Active,FirstCreated,LastLogin,Email")] SystemUser systemUser)
        {
            if (ModelState.IsValid)
            {
                db.SystemUsers.Add(systemUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(systemUser));
        }
Exemplo n.º 2
0
        public ActionResult Create(Transaction transaction, string selektovanaFirma = "")
        //[Bind(Include = "TransactionID,CompanyId,TransactionType,TransactionDate,In,Out,ResponsiblePerson,Comment,Active")]
        {
            if (ModelState.IsValid)
            {
                try
                {
                    transaction.Active = true;
                    var firstOrDefault = this.db.Companies
                                         .FirstOrDefault(x => x.Active && x.CompanyDescription == selektovanaFirma);
                    if (firstOrDefault
                        != null)
                    {
                        transaction.CompanyId = firstOrDefault.CompanyId;
                    }
                    if (transaction.TransactionType == PrevodSrb.Produkcija)
                    {
                        if (transaction.Amount > 0)
                        {
                            firstOrDefault.UpdatedOn = DateTime.Now;
                        }
                        else
                        {
                            TempData["msg"] = "Ako upisujete transakciju produkcija, mora da se unese iznos koji je veći od nule";
                            return(RedirectToAction("Index"));
                        }
                    }
                    ;

                    transaction.ResponsiblePerson = Prenosna.DajJuzerAjDi(Session["UserID"]);
                    transaction.TransactionDate   = DateTime.Now;

                    db.Transactions.Add(transaction);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    TempData["msg"] = Prenosna.Poruka(PrevodSrb.Niste_ulogovani);
                    return(RedirectToAction("Login", "Login"));
                }
            }

            //ViewBag.ResponsiblePerson = new SelectList(db.Users, "UserId", "Nick", Transaction.ResponsiblePerson);
            return(View(transaction));
        }
Exemplo n.º 3
0
 public static void SnimiDb(ModelEF db)
 {
     try
     {
         db.SaveChanges();
     }
     catch (DbEntityValidationException dbEx)
     {
         Greskonja(dbEx);
     }
 }