Ejemplo n.º 1
0
 public bool ValidCreateObject(LastEmployment lastEmployment, IEmployeeService _employeeService)
 {
     VHasEmployee(lastEmployment, _employeeService);
     if (!isValid(lastEmployment))
     {
         return(false);
     }
     VHasCompany(lastEmployment);
     if (!isValid(lastEmployment))
     {
         return(false);
     }
     VHasTitle(lastEmployment);
     //if (!isValid(lastEmployment)) { return false; }
     //VHasReason(lastEmployment);
     if (!isValid(lastEmployment))
     {
         return(false);
     }
     VHasStartDate(lastEmployment);
     if (!isValid(lastEmployment))
     {
         return(false);
     }
     VHasEndDate(lastEmployment);
     return(isValid(lastEmployment));
 }
Ejemplo n.º 2
0
 public LastEmployment VHasStartDate(LastEmployment lastEmployment)
 {
     if (lastEmployment.StartDate == null || lastEmployment.StartDate.Equals(DateTime.FromBinary(0)))
     {
         lastEmployment.Errors.Add("StartDate", "Tidak valid");
     }
     return(lastEmployment);
 }
Ejemplo n.º 3
0
 public LastEmployment VHasTitle(LastEmployment lastEmployment)
 {
     if (String.IsNullOrEmpty(lastEmployment.Title) || lastEmployment.Title.Trim() == "")
     {
         lastEmployment.Errors.Add("Title", "Tidak boleh kosong");
     }
     return(lastEmployment);
 }
Ejemplo n.º 4
0
 public LastEmployment VHasReason(LastEmployment lastEmployment)
 {
     if (String.IsNullOrEmpty(lastEmployment.ResignReason) || lastEmployment.ResignReason.Trim() == "")
     {
         lastEmployment.Errors.Add("ResignReason", "Tidak boleh kosong");
     }
     return(lastEmployment);
 }
Ejemplo n.º 5
0
 public LastEmployment VHasCompany(LastEmployment lastEmployment)
 {
     if (String.IsNullOrEmpty(lastEmployment.Company) || lastEmployment.Company.Trim() == "")
     {
         lastEmployment.Errors.Add("Company", "Tidak boleh kosong");
     }
     return(lastEmployment);
 }
Ejemplo n.º 6
0
        public LastEmployment VHasEmployee(LastEmployment lastEmployment, IEmployeeService _employeeService)
        {
            Employee employee = _employeeService.GetObjectById(lastEmployment.EmployeeId);

            if (employee == null)
            {
                lastEmployment.Errors.Add("Employee", "Tidak valid");
            }
            return(lastEmployment);
        }
Ejemplo n.º 7
0
 public LastEmployment VHasEndDate(LastEmployment lastEmployment)
 {
     if (lastEmployment.EndDate == null || lastEmployment.EndDate.Equals(DateTime.FromBinary(0)))
     {
         lastEmployment.Errors.Add("EndDate", "Tidak valid");
     }
     else if (lastEmployment.EndDate.GetValueOrDefault().Date < lastEmployment.StartDate.Date)
     {
         lastEmployment.Errors.Add("EndDate", "Harus lebih besar atau sama dengan Start Date");
     }
     return(lastEmployment);
 }
Ejemplo n.º 8
0
        public string PrintError(LastEmployment obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
Ejemplo n.º 9
0
        public LastEmployment CreateObject(string Company, string Title, DateTime StartDate, Nullable <DateTime> EndDate, string ResignReason, IEmployeeService _employeeService)
        {
            LastEmployment lastEmployment = new LastEmployment
            {
                Company      = Company,
                Title        = Title,
                StartDate    = StartDate,
                EndDate      = EndDate,
                ResignReason = ResignReason,
            };

            return(this.CreateObject(lastEmployment, _employeeService));
        }
Ejemplo n.º 10
0
        public bool isValid(LastEmployment obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
Ejemplo n.º 11
0
 public bool ValidDeleteObject(LastEmployment lastEmployment)
 {
     lastEmployment.Errors.Clear();
     return(isValid(lastEmployment));
 }
Ejemplo n.º 12
0
 public bool ValidUpdateObject(LastEmployment lastEmployment, IEmployeeService _employeeService)
 {
     lastEmployment.Errors.Clear();
     ValidCreateObject(lastEmployment, _employeeService);
     return(isValid(lastEmployment));
 }
Ejemplo n.º 13
0
 public bool isValid(LastEmployment obj)
 {
     //  bool isValid = !obj.Errors.Any();
     return(true);
 }
Ejemplo n.º 14
0
 public LastEmployment SoftDeleteObject(LastEmployment lastEmployment)
 {
     return(lastEmployment = _validator.ValidDeleteObject(lastEmployment) ?
                             _repository.SoftDeleteObject(lastEmployment) : lastEmployment);
 }
Ejemplo n.º 15
0
 public LastEmployment UpdateObject(LastEmployment lastEmployment, IEmployeeService _employeeService)
 {
     return(lastEmployment = _validator.ValidUpdateObject(lastEmployment, _employeeService) ? _repository.UpdateObject(lastEmployment) : lastEmployment);
 }
Ejemplo n.º 16
0
 public LastEmployment CreateObject(LastEmployment lastEmployment, IEmployeeService _employeeService)
 {
     lastEmployment.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(lastEmployment, _employeeService) ? _repository.CreateObject(lastEmployment) : lastEmployment);
 }