Example #1
0
        public R.ResultVm <bool> AddCheckin(string serverName, Checkin checkin)
        {
            var result = new R.ResultVm <bool>().FromEmptyFailure();

            Demand <string> .That(serverName, "serverName").HasNonEmptyValue().HasMaxChars(255).Result(result);

            Demand <double> .That(checkin.RamUtilization, "checkin.RamUtilization").IsGreaterThan(0.0D).Result(result);

            Demand <double> .That(checkin.CpuUtilization, "checkin.CpuUtilization").IsGreaterThan(0.0D).IsLessThanOrEqualTo(1.0D).Result(result);

            //Demand<DateTime>.That(checkin.SampleTime, "checkin.SampleTime").IsAfter(DateTime.Now.AddMinutes(-10.0D)).IsBefore(DateTime.Now.AddMinutes(10.00D)).Result(result);

            if (result.Errors.Count == 0)
            {
                try
                {
                    result = new ResultVm <bool>().FromSuccessObject(_repo.AddCheckin(serverName, checkin));
                }
                catch (Exception ex)
                {
                    result = new ResultVm <bool>().FromException(ex);
                }
            }
            else
            {
                result.Data = false;
            }

            return(result);
        }