public ActionResult Edit(long barcode)
        {
            Crew         crew     = RepoCrew.FindByPk(barcode);
            CrewFormStub formStub = new CrewFormStub(crew);

            return(View("Form", formStub));
        }
        public ActionResult Create(CrewFormStub model)
        {
            //bool isNameExist = RepoContractor.Find().Where(p => p.name == model.Name).Count() > 0;

            if (ModelState.IsValid)
            {
                Crew dbItem = new Crew();
                dbItem = model.GetDbObject(dbItem);
                dbItem.tanggal_daftar = DateTime.Now;
                string temp = dbItem.tanggal_daftar.ToString("ddMMyyyy") + (RepoCrew.Count() + 1).ToString("D3");
                dbItem.barcode = long.Parse(temp);

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

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

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("Form", model));
            }
        }
        public ActionResult Edit(CrewFormStub model)
        {
            //bool isNameExist = RepoKompetitor.Find().Where(p => p.name == model.Name && p.id != model.Id).Count() > 0;

            if (ModelState.IsValid)
            {
                Crew     dbItem = RepoCrew.FindByPk(model.Barcode);
                DateTime temp   = dbItem.tanggal_daftar;
                dbItem = model.GetDbObject(dbItem);
                dbItem.tanggal_daftar = temp;

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

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

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("Form", model));
            }
        }
Beispiel #4
0
        public ActionResult CreateCrew(CrewFormStub model)
        {
            //bool isNameExist = RepoContractor.Find().Where(p => p.name == model.Name).Count() > 0;

            if (ModelState.IsValid)
            {
                Crew dbItem = new Crew();
                dbItem = model.GetDbObject(dbItem);

                //Generate ID untuk Crew
                string barcode = DateTime.Now.ToString("ddMMyyyy");
                dbItem.Barcode = barcode + "-" + (RepoCrew.FindAll().Count + 1).ToString("D3");

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

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

                return(RedirectToAction("CrewCRUD"));
            }
            else
            {
                return(View("FormCrew", model));
            }
        }
        public ActionResult Create()
        {
            CrewFormStub formStub = new CrewFormStub();

            return(View("Form", formStub));
        }