Ejemplo n.º 1
0
        public bool AddUnicorn(UnicornDTO data)
        {
            try
            {
                var record = new Unicorn()
                {
                    UnicornName   = data.UnicornName,
                    UnicornNumber = data.UnicornNumber,
                    UnicornOwner  = data.UnicornOwner,
                    CreatedBy     = "admin",
                    CreatedDate   = DateTime.Now,
                };
                Create(record);
                _uow.Save();
                return(true);
            }

            catch (Exception ex)
            {
                ex.Data.Add("AddUnicorn", "An error occurred while trying to create AddUnicorn Record - DAL");
                Tracer.Error(ex);
                _uow.Rollback();
                return(false);
            }
        }
 public bool UpdateUnicorn(UnicornDTO data)
 {
     using (var uow = new UnitOfWork())
     {
         try
         {
             var isAdded = uow.UniCorn.UpdateUnicorn(data);
             if (isAdded == true)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             ex.Data.Add("UpdateUnicorn", "An error occurred while trying to UpdateUnicorn Record - BLL");
             uow.Rollback();
             Tracer.Error(ex);
             return(false);
         }
     }
 }
Ejemplo n.º 3
0
        public ActionResult Create(UnicornDTO model)
        {
            var isAdded = _UnicornBusinessLayer.AddUnicorn(model);


            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public ActionResult Update(int Id)
        {
            UnicornDTO model = new UnicornDTO();

            model = _UnicornBusinessLayer.GetById(Id);
            return(View(model));
        }
Ejemplo n.º 5
0
 public bool UpdateUnicorn(UnicornDTO data)
 {
     try
     {
         var unicorndata = GetQuerable(x => x.Id == data.Id).FirstOrDefault();
         unicorndata.UnicornName   = data.UnicornName;
         unicorndata.UnicornNumber = data.UnicornNumber;
         unicorndata.UnicornOwner  = data.UnicornOwner;
         unicorndata.CreatedBy     = "Admin";
         unicorndata.CreatedDate   = DateTime.Now;
         Update(unicorndata);
         _uow.Save();
         return(true);
     }
     catch (Exception ex)
     {
         ex.Data.Add("UpdateUnicorn", "An error occurred while trying to create UpdateUnicorn Record - DAL");
         Tracer.Error(ex);
         _uow.Rollback();
         return(false);
     }
 }
Ejemplo n.º 6
0
        public ActionResult Update(UnicornDTO model)
        {
            var isUpdated = _UnicornBusinessLayer.UpdateUnicorn(model);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult Create()
        {
            UnicornDTO model = new UnicornDTO();

            return(View(model));
        }