Ejemplo n.º 1
0
        public ActionResult Add(ClientDto newClient)
        {
            try
            {
                _clientService.Insert(newClient);

                return RedirectToAction("List", new { Id = EnumHelper.EnumTextToInt(newClient.ClientType, typeof(Enums.ClientType)) });
            }
            catch
            {
                ViewBag.FormMode = "Add";
                ViewBag.ClientTypeList = new SelectList(_clientService.FetchClientTypes(), "Id", "Name");
                ViewBag.ClientTypeFilter = EnumHelper.ClientTypeToEnum(newClient.ClientType);
                return View("Edit");
            }
        }
Ejemplo n.º 2
0
        public void Update(ClientDto editedItem)
        {
            //Begin DB transaction
            _clientDb.BeginTransaction();

            try
            {
                //Get record
                _clientDb.Update(Mapper.Map<ClientDto, ClientDomain>(editedItem));
                _clientDb.CompleteTransaction();
                Logger.Info(String.Format("Client #{0} Updated Successfully", editedItem.Id));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                _clientDb.AbortTransaction();
                throw;
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id, ClientDto editedClient)
        {
            try
            {
                _clientService.Update(editedClient);

                return RedirectToAction("List", new { Id = EnumHelper.EnumTextToInt(editedClient.ClientType, typeof(Enums.ClientType)) });
            }
            catch
            {
                ViewBag.FormMode = "Edit";
                ViewBag.ClientTypeFilter = EnumHelper.ClientTypeToEnum(editedClient.ClientType);
                return View();
            }
        }
Ejemplo n.º 4
0
        public void Insert(ClientDto newRecord)
        {
            //Begin DB transaction
            _clientDb.BeginTransaction();

            try
            {
                //Insert record
                _clientDb.Insert(Mapper.Map<ClientDto, ClientDomain>(newRecord));
                _clientDb.CompleteTransaction();

                Logger.Info(String.Format("{0} Client '{1}' Inserted Successfully", newRecord.ClientType, newRecord.FullName));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                _clientDb.AbortTransaction();
                throw;
            }
        }