Beispiel #1
0
        public IHttpActionResult Add(Rancher rancher)
        {
            RancherResponse response = new RancherResponse();

            try
            {
                Rancher rancherSaved = rancherBL.InsertRancher(rancher);
                response.Rancher = rancherSaved;
                response.Success = true;
            }
            catch (RancherException ex)
            {
                response.ErrorCode    = ex.Error;
                response.ErrorMessage = "Error. " + ex.Error.ToString();
                response.Rancher      = null;
                response.Success      = false;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.Rancher      = null;
                response.Success      = false;
            }
            return(Ok(response));
        }
Beispiel #2
0
        private static void MigrateRanchers()
        {
            List <string>  exceptions = new List <string>();
            List <Rancher> ranchers   = RancherOld.GetRanchers();
            RancherBL      rancherBL  = new RancherBL(connectionString);

            foreach (Rancher rancher in ranchers)
            {
                try
                {
                    rancherBL.InsertRancher(rancher);
                }
                catch (Exception ex)
                {
                    exceptions.Add(rancher.Name + ". Error " + ex.Message);
                }
            }
            foreach (string ex in exceptions)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }