예제 #1
0
 public WhitelistPresentationStub(Crew_Whitelist dbItem)
 {
     this.Id           = dbItem.Id;
     this.Barcode      = dbItem.Barcode;
     this.TanggalAwal  = (DateTime)dbItem.Tanggal_Awal;
     this.TanggalAkhir = (DateTime)dbItem.Tanggal_Akhir;
 }
예제 #2
0
 public WhitelistFormStub(Crew_Whitelist dbItem)
 {
     Id           = dbItem.Id;
     Barcode      = dbItem.Barcode;
     TanggalAwal  = (DateTime)dbItem.Tanggal_Awal;
     TanggalAkhir = (DateTime)dbItem.Tanggal_Akhir;
 }
예제 #3
0
        public ActionResult EditWhitelist(WhitelistFormStub model)
        {
            //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0;

            if (ModelState.IsValid)
            {
                Crew_Whitelist dbItem = RepoWhite.FindByPk(model.Id);
                dbItem = model.GetDbObject(dbItem);

                try
                {
                    RepoWhite.Save(dbItem);
                }
                catch (Exception e)
                {
                    return(View("FormCrew", model));
                }

                //message
                string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString();
                this.SetMessage(model.Id.ToString(), template);

                return(View("CrewWhitelist"));
            }
            else
            {
                return(View("FormWhitelist", model));
            }
        }
예제 #4
0
 public Crew_Whitelist GetDbObject(Crew_Whitelist dbItem)
 {
     dbItem.Id            = this.Id;
     dbItem.Barcode       = this.Barcode;
     dbItem.Tanggal_Awal  = this.TanggalAwal;
     dbItem.Tanggal_Akhir = this.TanggalAkhir;
     return(dbItem);
 }
예제 #5
0
        public JsonResult DeleteWhitelist(int id)
        {
            string         template = "";
            ResponseModel  response = new ResponseModel(true);
            Crew_Whitelist dbItem   = RepoWhite.FindByPk(id);

            RepoWhite.Delete(dbItem);

            return(Json(response));
        }
예제 #6
0
 public void Save(Crew_Whitelist dbItem)
 {
     if (dbItem.Id == 0) //create
     {
         context.Crew_Whitelist.Add(dbItem);
     }
     else //edit
     {
         var entry = context.Entry(dbItem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
예제 #7
0
        public ActionResult EditWhitelist(int id)
        {
            Crew_Whitelist white   = RepoWhite.FindByPk(id);
            List <object>  newList = new List <object>();

            foreach (var crew in context.Crews)
            {
                newList.Add(new
                {
                    Id   = crew.Barcode,
                    Name = crew.Barcode + " " + crew.Nama
                });
            }
            this.ViewData["Crew"] = new SelectList(newList, "Name", "Id");

            WhitelistFormStub formStub = new WhitelistFormStub(white);

            return(View("FormWhitelist", formStub));
        }
예제 #8
0
 public void Delete(Crew_Whitelist dbItem)
 {
     context.Crew_Whitelist.Remove(dbItem);
     context.SaveChanges();
 }