Exemple #1
0
        public static CantonVM MapToVM(Canton canton)
        {
            CantonVM cantonVM = new CantonVM()
            {
                CantonId = canton.CantonId,
                Name     = canton.Name
            };

            return(cantonVM);
        }
Exemple #2
0
        public static Canton MapFromVM(CantonVM cantonVM)
        {
            Canton canton = new Canton()
            {
                CantonId = cantonVM.CantonId,
                Name     = cantonVM.Name
            };

            return(canton);
        }
 public static ObjectResponse <bool> Update(Canton canton)
 {
     try
     {
         using (var db = new AppContext())
         {
             db.Entry(canton).State = EntityState.Modified;
             db.SaveChanges();
             return(new ObjectResponse <bool>(true, "Edicion exitosa"));
         }
     }
     catch (Exception e)
     {
         return(new ObjectResponse <bool>(false, $"Edicion fallida {e.InnerException}"));
     }
 }
 public static ObjectResponse <bool> Create(Canton canton)
 {
     try
     {
         using (var db = new AppContext())
         {
             db.Cantons.Add(canton);
             db.SaveChanges();
             return(new ObjectResponse <bool>(true, "Creacion exitosa"));
         }
     }
     catch (Exception e)
     {
         return(new ObjectResponse <bool>(false, $"Creacion fallida {e.InnerException}"));
     }
 }