示例#1
0
        public OperationResult Create(Protfolio protfolio)
        {
            OperationResult result = new OperationResult();

            try
            {
                AppleLaLaRepository <Protfolio> repo_p = new AppleLaLaRepository <Protfolio>(context);
                var CreateDate = new Protfolio
                {
                    Designer_id        = protfolio.Designer_id,
                    Service_details_Id = protfolio.Service_details_Id,
                    Photo_url          = protfolio.Photo_url,
                    Year             = protfolio.Year,
                    Month            = protfolio.Month,
                    Color_type       = protfolio.Color_type,
                    Description      = protfolio.Description,
                    Create_date      = DateTime.Now,
                    Last_updata_date = DateTime.Now,
                };
                repo_p.Create(CreateDate);
                context.SaveChanges();
                result.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }
            return(result);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Protfolio protfolio = db.Protfolio.Find(id);

            db.Protfolio.Remove(protfolio);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Protfolio_id,Designer_id,Service_details_Id,Photo_url,Year,Month,Color_type,Description,Create_date,Last_updata_date")] Protfolio protfolio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(protfolio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Designer_id        = new SelectList(db.Designer, "Designer_id", "Name", protfolio.Designer_id);
     ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", protfolio.Service_details_Id);
     return(View(protfolio));
 }
        // GET: Protfolios/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Protfolio protfolio = db.Protfolio.Find(id);

            if (protfolio == null)
            {
                return(HttpNotFound());
            }
            return(View(protfolio));
        }
        // GET: Protfolios/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Protfolio protfolio = db.Protfolio.Find(id);

            if (protfolio == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Designer_id        = new SelectList(db.Designer, "Designer_id", "Name", protfolio.Designer_id);
            ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", protfolio.Service_details_Id);
            return(View(protfolio));
        }
        public ActionResult Create([Bind(Include = "Protfolio_id,Designer_id,Service_details_Id,Photo_url,Year,Month,Color_type,Description")] Protfolio protfolio)
        {
            if (ModelState.IsValid)
            {
                ProtfoloService pservice = new ProtfoloService();
                var             result   = pservice.Create(protfolio);
                if (result.IsSuccessful)
                {
                    return(RedirectToAction("Index"));
                }
            }


            ViewBag.Designer_id        = new SelectList(db.Designer, "Designer_id", "Name", protfolio.Designer_id);
            ViewBag.Service_details_Id = new SelectList(db.Service_details, "Service_details_Id", "Name", protfolio.Service_details_Id);
            return(View(protfolio));
        }