Exemplo n.º 1
0
        public IActionResult Create(web_db.TblSalMali model, string az, string ta)
        {
            var row = db.TblSalMalis.Find(model.Id);

            if (row == null)
            {
                row = new web_db.TblSalMali()

                {
                    Id = (db.TblSalMalis.Max(a => (int?)a.Id) ?? 0) + 1
                };
                db.TblSalMalis.Add(row);
                foreach (var item in db.TblContractTypes.Where(a => a.FkSalmali == User._getuserSalMaliDef()))
                {
                    var itc = item.Clone2();
                    itc.Id        = Guid.NewGuid();
                    itc.FkSalmali = row.Id;

                    db.TblContractTypes.Add(itc);
                }
            }
            row.IsOpen    = model.IsOpen;
            row.IsOrginal = model.IsOrginal;
            row.Sal       = model.Sal;
            row.SalAz     = az.ToDate();
            row.SalTa     = ta.ToDate();
            db.SaveChanges();
            cl._ListSalmali       = db.TblSalMalis.OrderBy(a => a.Id).ToList();
            cl.__ListContractType = db.TblContractTypes.OrderBy(a => a.FkSalmali).ThenBy(a => a.Code).ToList();

            return(RedirectToAction("index"));
        }
Exemplo n.º 2
0
        public IActionResult Create(int id)
        {
            var x = db.TblSalMalis.Find(id);

            if (x == null)
            {
                x = new web_db.TblSalMali
                {
                    IsOpen = true,
                };
            }
            ViewBag.us  = db.TblUsers.Where(a => a.IsActive).OrderBy(a => a.Title).ToList();
            ViewBag.usS = db.TblUserSals.Where(a => a.FkSal == id).Select(a => a.FkUser).ToList();

            return(View(x));
        }