Ejemplo n.º 1
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Assign_Id,User_Id,Aktif,Pengecer_Id,Urea,NPK,SP36,ZA,Organik")] Assigns assign)
        {
            string dateToday       = DateTime.Now.ToString("M/dd/yyyy");
            string timeToday       = DateTime.Now.ToString("h:mm:ss tt");
            Claim  sessionUsername = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier);
            string userName        = sessionUsername.Value;

            if (ModelState.IsValid)
            {
                var dbassign = db.Assigns.Create();
                dbassign.Assign_Id   = assign.Assign_Id;
                dbassign.User_Id     = assign.User_Id;
                dbassign.Aktif       = assign.Aktif;
                dbassign.Pengecer_Id = assign.Pengecer_Id;
                dbassign.Edited_by   = userName;
                dbassign.Date_Edited = dateToday;
                dbassign.Time_Edited = timeToday;
                dbassign.Urea        = assign.Urea;
                dbassign.NPK         = assign.NPK;
                dbassign.SP36        = assign.SP36;
                dbassign.ZA          = assign.ZA;
                dbassign.Organik     = assign.Organik;

                db.Assigns.Add(dbassign);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.User_Id     = new SelectList(db.Users, "User_Id", "Name", assign.User_Id);
            ViewBag.Pengecer_Id = new SelectList(db.Pengecers, "Pengecer_Id", "Name", assign.Pengecer_Id);
            return(View(assign));
        }
Ejemplo n.º 2
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Assigns assign = db.Assigns.Find(id);

            db.Assigns.Remove(assign);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public IActionResult AddAssign([FromBody] Assigns Assign)
 {
     if (Assign != null)
     {
         _UnitOfwork.entity.Insert(Assign);
     }
     return(Ok());
 }
Ejemplo n.º 4
0
        public void UpdateAssigns(int id, Assigns Assigns)
        {
            var e = _TicketsContext.Assigns.Where(m => m.AssignID == id).FirstOrDefault();

            if (e != null)
            {
                e.AssignName = Assigns.AssignName;
                _TicketsContext.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public Return AssignMenuItem([FromBody] Assigns assigns)
        {
            try
            {
                menuDomain.InsertAssignsAndRemoveUnassigns(assigns.MenuId, assigns.All, assigns.Selecteds);

                return(new Success(Suc.SuccessfullyAssignedMenuItem));
            }
            catch (Exception ex)
            {
                return(new Error(ex));
            }
        }
Ejemplo n.º 6
0
        public Return AssignProfile([FromBody] Assigns assigns)
        {
            try
            {
                profileDomain.InsertAssignsAndRemoveUnassigns(assigns.ProfileId, assigns.All, assigns.Selecteds);

                return(new Success(Suc.SuccessfullyAssignedProfile));
            }
            catch (Exception ex)
            {
                return(new Error(ex));
            }
        }
Ejemplo n.º 7
0
        // GET: /Assigns/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Assigns assign = db.Assigns.Find(id);

            if (assign == null)
            {
                return(HttpNotFound());
            }
            return(View(assign));
        }
Ejemplo n.º 8
0
        // GET: /Assigns/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Assigns assign = db.Assigns.Find(id);

            if (assign == null)
            {
                return(HttpNotFound());
            }
            ViewBag.User_Id     = new SelectList(db.Users, "User_Id", "Name", assign.User_Id);
            ViewBag.Pengecer_Id = new SelectList(db.Pengecers, "Pengecer_Id", "Name", assign.Pengecer_Id);
            return(View(assign));
        }
Ejemplo n.º 9
0
        //[ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "Assign_Id,User_Id,Aktif,Pengecer_Id,Urea,NPK,SP36,ZA,Organik")] Assigns assign)
        {
            string dateToday       = DateTime.Now.ToString("M/dd/yyyy");
            string timeToday       = DateTime.Now.ToString("h:mm:ss tt");
            Claim  sessionUsername = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier);
            string userName        = sessionUsername.Value;

            if (ModelState.IsValid)
            {
                assign.Time_Edited     = timeToday;
                assign.Date_Edited     = dateToday;
                assign.Edited_by       = userName;
                db.Entry(assign).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.User_Id     = new SelectList(db.Users, "User_Id", "Name", assign.User_Id);
            ViewBag.Pengecer_Id = new SelectList(db.Pengecers, "Pengecer_Id", "Name", assign.Pengecer_Id);
            return(View(assign));
        }
Ejemplo n.º 10
0
 public ActionResult UserRelation(Assigns model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDbContext())
         {
             //var queryAssign = db.Assigns.Where(u => u.Id_user == model.Id_user && u.Kode_Pengecer == model.Kode_Pengecer).Select(u => u.Id_ass) ;
             var queryAssign = db.Assigns.FirstOrDefault(u => u.User_Id == model.User_Id && u.Pengecer_Id == model.Pengecer_Id);
             if (queryAssign == null)
             {
                 string timeToday = DateTime.Now.ToString("h:mm:ss tt");
                 string dateToday = DateTime.Now.ToString("M/dd/yyyy");
                 var    assign    = db.Assigns.Create();
                 assign.User_Id     = model.User_Id;
                 assign.Pengecer_Id = model.Pengecer_Id;
                 assign.Urea        = model.Urea;
                 assign.NPK         = model.NPK;
                 assign.SP36        = model.SP36;
                 assign.ZA          = model.ZA;
                 assign.Organik     = model.Organik;
                 assign.Time_Edited = timeToday;
                 assign.Date_Edited = dateToday;
                 db.Assigns.Add(assign);
                 db.SaveChanges();
             }
             else
             {
                 return(RedirectToAction("UserRelation"));
                 //return RedirectToAction("RegistrationPengecer");
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "One or more fields have been");
     }
     return(View());
 }
Ejemplo n.º 11
0
 public IActionResult UpdateAssign(int id, [FromBody] Assigns Assign)
 {
     _UnitOfwork.entity.UpdateAssigns(id, Assign);
     return(Ok(Assign));
 }