예제 #1
0
        public ActionResult Partners_Create([DataSourceRequest]DataSourceRequest request, Partner partner)
        {
            if (ModelState.IsValid)
            {
                var entity = new Partner
                {
                    Name = partner.Name,
                    Logo = partner.Logo,
                    Website = partner.Website,
                    Description = partner.Description,
                    JoinedOn = partner.JoinedOn,
                    PartnershipLevel = partner.PartnershipLevel
                };

                db.Partners.Add(entity);
                db.SaveChanges();
                partner.Id = entity.Id;
            }

            return Json(new[] { partner }.ToDataSourceResult(request, ModelState));
        }
예제 #2
0
        public ActionResult Partners_Update([DataSourceRequest]DataSourceRequest request, Partner partner)
        {
            if (ModelState.IsValid)
            {
                var entity = new Partner
                {
                    Id = partner.Id,
                    Name = partner.Name,
                    Logo = partner.Logo,
                    Website = partner.Website,
                    Description = partner.Description,
                    JoinedOn = partner.JoinedOn,
                    PartnershipLevel = partner.PartnershipLevel
                };

                db.Partners.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return Json(new[] { partner }.ToDataSourceResult(request, ModelState));
        }