Beispiel #1
0
        public ActionResult ResourceAuthorIndex()
        {
            ResourceAuthorModel db = new ResourceAuthorModel();

            db.ResourceAuthorList = _iResourceAuthorService.GetResourceAuthorList();
            return(View(db));
        }
Beispiel #2
0
 public ActionResult CreateEditResourceAuthor(ResourceAuthorModel raModel)
 {
     if (ModelState.IsValid)
     {
         var result = _iResourceAuthorService.CreateEditResourceAuthor(raModel);
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(rModel, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #3
0
        public ActionResult CreateEditResourceAuthor(int?AuthorId)
        {
            ResourceAuthorModel raModel = new ResourceAuthorModel();

            ViewBag.CountryName = new SelectList(_iCountry.GetCountryList(), "CountryId", "CountryName");

            if (AuthorId != null)
            {
                raModel = _iResourceAuthorService.GetResourceAuthorList().Where(x => x.AuthorId == AuthorId).FirstOrDefault();
            }

            return(PartialView("_CreateEditResourceAuthor", raModel));
        }
        public ReturnMessageModel CreateEditResourceAuthor(ResourceAuthorModel raModel)
        {
            try
            {
                using (PointOfSaleEntities _context = new PointOfSaleEntities())
                {
                    var rtRow = _context.ResourceAuthors.Where(x => x.AuthorId == raModel.AuthorId).FirstOrDefault();
                    if (rtRow == null)
                    {
                        rtRow = new ResourceAuthor();
                    }

                    rtRow.Author      = raModel.Author;
                    rtRow.Nationality = raModel.Nationality;
                    rtRow.Genere      = raModel.Genere;
                    rtRow.IsActive    = raModel.IsActive;

                    if (raModel.AuthorId == 0)
                    {
                        rtRow.CreatedBy   = WebSecurity.CurrentUserId;
                        rtRow.CreatedDate = System.DateTime.Now;
                        _context.ResourceAuthors.Add(rtRow);
                        _context.SaveChanges();
                    }
                    else
                    {
                        rtRow.ModifiedBy   = WebSecurity.CurrentUserId;
                        rtRow.ModifiedDate = System.DateTime.Now;
                        _context.ResourceAuthors.Attach(rtRow);
                        _context.Entry(rtRow).State = EntityState.Modified;
                        _context.SaveChanges();
                    }



                    rModel.Msg     = "Resource Type Saved Successfully";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "Resource Type Saved Failed";
                rModel.Success = false;
                return(rModel);
            }
        }