Esempio n. 1
0
 public ActionResult CreateCompetitor(CompetitorViewModel cvm)
 {
     try
     {
         cvm.Id = Guid.NewGuid();
         _competitorViewModeBuilder.Save(cvm);
         TempData["msg"] = "Competitor Successfully Created";
         _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Create", "Competitor", DateTime.Now);
         return RedirectToAction("ListCompetitors");
     }
     catch (DomainValidationException dve)
     {
         ValidationSummary.DomainValidationErrors(dve, ModelState);
         _log.Debug("Failed to create competitor " + dve.Message);
         _log.Error("Failed to create competitor " + dve.ToString());
         return View();
     }
     catch (Exception ex)
     {
         ViewBag.msg = ex.Message;
         _log.Debug("Failed to create competitor " + ex.Message);
         _log.Error("Failed to create competitor " + ex.ToString());
         return View();
     }
 }
        public void Save(CompetitorViewModel cvm)
        {
            Competitor compe = new Competitor(cvm.Id) 
            {
                Name = cvm.Name,
                 ContactPerson=cvm.ContactPerson,
                  City=cvm.City,
                   Lattitude=cvm.Lattitude,
                    Longitude=cvm.Longitude,
                     PhysicalAddress=cvm.PhysicalAddress,
                      PostalAddress=cvm.PostalAddress,
                       Telephone=cvm.Telephone,
                       

            };
            _competitorRepository.Save(compe);
        }