Ejemplo n.º 1
0
        public HttpResponseMessage ArchiveEmployee([FromBody] EmployeeDataContext instanceDataModel)
        {
            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                EmployeeData dtEmployee = employeeDB.GetEmployeeById(instanceDataModel.employeeId);
                if (dtEmployee != null)
                {
                    int isArchived = employeeDB.ArchiveEmployee(instanceDataModel.employeeId);
                    if (isArchived > 0)
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = Messages.EMPTY }));
                        }
                    }
                    else
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ARCHIVE_EN_DB_ERROR, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ARCHIVE_DB_ERROR, data = Messages.EMPTY }));
                        }
                    }
                }
                else
                {
                    if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EN_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                    }
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }