internal HttpResponseMessage TranslatedTermDetail(HttpRequestMessage request, TranslatedTermDTO cqDTO)
        {
            var ur   = new TranslatedTermRepository();
            var u    = new TranslatedTerm();
            var data = ur.GetById(int.Parse(cqDTO.TranslationID));
            var col  = new Collection <Dictionary <string, string> >();



            var dic = new Dictionary <string, string>();

            dic.Add("TranslationID", data.TranslationID.ToString());
            dic.Add("TermTranslated", data.TermTranslated);
            dic.Add("EnglishTermID", data.EnglishTermID.ToString());
            dic.Add("LanguageID", data.LanguageID.ToString());
            dic.Add("Term", data.EnglishTerm.Term.ToString());
            col.Add(dic);


            var retVal = new GenericDTO
            {
                ReturnData = col
            };

            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
        internal HttpResponseMessage DepartmentDates(HttpRequestMessage request, DepartmentTotalDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new DepartmentTotalRepository();
                var u  = new DepartmentTotal();
                if (cqDTO.DTDate != null)
                {
                    cqDTO.Start_DTDate = DateTime.Parse(cqDTO.DTDate).ToString();
                    cqDTO.End_DTDate   = DateTime.Parse(cqDTO.DTDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_DTDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_DTDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_DTDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_DTDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_DTDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_DTDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                data = data.GroupBy(x => x.DTDate).Select(x => x.First()).OrderBy(x => x.DTDate).ToList();
                var col = new Collection <Dictionary <string, string> >();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();
                    dic.Add("DTDate", item.DTDate.ToShortDateString());
                    col.Add(dic);
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #3
0
 public static bool logar(string usuario, string senha, out string erro)
 {
     try
     {
         erro = "";
         var        json = WebService.downloadJson("/Usuario/recuperar");
         GenericDTO dto  = JsonConvert.DeserializeObject <GenericDTO>(json);
         dto.payload = ((JArray)dto.payload).ToObject <List <Usuario> >();
         foreach (Usuario user in (List <Usuario>)dto.payload)
         {
             if (user.login.Equals(usuario) && user.senha.Equals(senha))
             {
                 logado        = true;
                 usuarioLogado = user;
                 return(logado);
             }
             else
             {
                 erro = "Login ou Senha Inválidos!";
             }
         }
     }
     catch (Exception e)
     {
         erro = e.Message;
     }
     return(false);
 }
Пример #4
0
        internal HttpResponseMessage UserDetail(HttpRequestMessage request, UserDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var    ur        = new UserRepository();
                var    u         = new User();
                var    predicate = ur.GetPredicate(cqDTO, u, companyId);
                var    data      = ur.GetByPredicate(predicate);
                var    col       = new Collection <Dictionary <string, string> >();
                string ufarms    = "";
                string uroles    = "";

                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("UserId", item.UserId.ToString());
                    dic.Add("FirstName", item.FirstName);
                    dic.Add("LastName", item.LastName);
                    dic.Add("EmailAddress", item.EmailAddress);
                    dic.Add("Phone", item.Phone);
                    dic.Add("StatusId", item.StatusId.ToString());

                    foreach (var farmitem in item.UserFarms)
                    {
                        ufarms = ufarms + farmitem.FarmId.ToString() + ",";
                    }
                    if (ufarms.Length > 0)
                    {
                        //ufarms = ufarms.Remove(uroles.Length - 1);
                        dic.Add("Farms", ufarms);
                    }
                    foreach (var roleitem in item.UserRoles)
                    {
                        uroles = uroles + roleitem.RoleId.ToString() + ",";
                    }
                    if (uroles.Length > 0)
                    {
                        //uroles = uroles.Remove(uroles.Length - 1) ;
                        dic.Add("Roles", uroles);
                    }
                    col.Add(dic);
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #5
0
        /// <summary>
        /// Returns the User as a DTO
        /// </summary>
        /// <returns>User represented as a DTO</returns>
        public GenericDTO toDTO()
        {
            GenericDTO dto = new GenericDTO("User");

            dto.put("1", auth);
            return(dto);
        }
        internal HttpResponseMessage ShiftEnds(HttpRequestMessage request, ShiftEndDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new ShiftEndRepository();
                var u  = new ShiftEnd();
                if (cqDTO.ShiftDate != null)
                {
                    cqDTO.Start_ShiftDate = DateTime.Parse(cqDTO.ShiftDate).ToString();
                    cqDTO.End_ShiftDate   = DateTime.Parse(cqDTO.ShiftDate).AddDays(1).ToString();
                }
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                data = data.OrderBy(x => x.ShiftDate).ToList();
                var col = new Collection <Dictionary <string, string> >();

                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("ShiftEndID", item.ShiftEndID.ToString());
                    dic.Add("DayFinishedFreezing", item.DayFinishedFreezing == null ? "" : DateTime.Parse(item.DayFinishedFreezing.ToString()).ToString("HH:mm"));
                    dic.Add("DayShiftFroze", item.DayShiftFroze == null ? "" : item.DayShiftFroze.ToString());
                    dic.Add("DowntimeMinutes", item.DowntimeMinutes == null ? "" : item.DowntimeMinutes.ToString());
                    dic.Add("EmployeesOnVacation", item.EmployeesOnVacation == null ? "" : item.EmployeesOnVacation.ToString());
                    dic.Add("FilletScaleReading", item.FilletScaleReading == null ? "" : item.FilletScaleReading.ToString());
                    dic.Add("FinishedFillet", item.FinishedFillet == null ? "" : DateTime.Parse(item.FinishedFillet.ToString()).ToString("HH:mm"));
                    dic.Add("FinishedKill", item.FinishedKill == null ? "" : DateTime.Parse(item.FinishedKill.ToString()).ToString("HH:mm"));
                    dic.Add("FinishedSkinning", item.FinishedSkinning == null ? "" : DateTime.Parse(item.FinishedSkinning.ToString()).ToString("HH:mm"));
                    dic.Add("InmateLeftEarly", item.InmateLeftEarly == null ? "" : item.InmateLeftEarly.ToString());
                    dic.Add("InLateOut", item.InLateOut == null ? "" : item.InLateOut.ToString());
                    dic.Add("NightFinishedFreezing", item.NightFinishedFreezing == null ? "" : DateTime.Parse(item.NightFinishedFreezing.ToString()).ToString("HH:mm"));
                    dic.Add("NightShiftFroze", item.NightShiftFroze == null ? "" : item.NightShiftFroze.ToString());
                    dic.Add("RegEmpLate", item.RegEmpLate == null ? "" : item.RegEmpLate.ToString());
                    dic.Add("RegEmpOut", item.RegEmpOut == null ? "" : item.RegEmpOut.ToString());
                    dic.Add("RegEmplLeftEarly", item.RegEmplLeftEarly == null ? "" : item.RegEmplLeftEarly.ToString());
                    dic.Add("ShiftDate", item.ShiftDate == null ? "" : item.ShiftDate.ToString());
                    dic.Add("TempEmpOut", item.TempEmpOut == null ? "" : item.TempEmpOut.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #7
0
        public HttpResponseMessage PondMortalityLast7Mortalities([FromBody] PondDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    UserId    = ur.ValidateUser(uDto.Key, out key, ref companyId);

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Chowtime"))
            {
                var      pr        = new PondRepository();
                var      ponddata  = pr.GetById(int.Parse(uDto.PondId));
                DateTime startdate = DateTime.Now;

                int i             = 0;
                int j             = 0;
                int pondDataCount = 0;

                var col = new Collection <Dictionary <string, string> >();
                while (pondDataCount < 7 && j < 10)
                {
                    var      db        = new AppEntities();
                    string   datepart  = startdate.AddDays(i).ToShortDateString();
                    DateTime begindate = DateTime.Parse(datepart);
                    DateTime enddate   = begindate.AddDays(1);
                    var      data      = db.Mortalities.Where(x => x.PondId == ponddata.PondId && x.MortalityDate >= begindate && x.MortalityDate < enddate).FirstOrDefault();
                    if (data != null)
                    {
                        var dic = new Dictionary <string, string>();

                        dic.Add("PondId", data.PondId.ToString());
                        dic.Add("MortalityId", data.MortalityId.ToString());
                        dic.Add("MortalityDate", data.MortalityDate.ToString());
                        dic.Add("MortalityPounds", data.MortalityPounds.ToString());
                        col.Add(dic);
                        pondDataCount++;
                        // reset j - haven't hit null territory yet
                        j = 0;
                    }
                    else
                    {
                        j++;
                    }
                    i--;
                }
                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #8
0
        protected static HttpResponseMessage ProcessValidationErrors(HttpRequestMessage request, Collection <Dictionary <string, string> > validationErrors, string key)
        {
            var retVal = new GenericDTO {
                Key        = key,
                ReturnData = validationErrors
            };

            return(request.CreateResponse(HttpStatusCode.BadRequest, retVal));
        }
Пример #9
0
        public HttpResponseMessage WeekDataAddOrEdit([FromBody] WeekDataDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    AbsenceId = 0;
            var    userId    = ur.ValidateUser(uDto.Key, out key, ref AbsenceId);

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (userId > 0)
            {
                var wer         = new AD_WeekDataRepository();
                var WeekEndDate = DateTime.Parse(uDto.AD_WeekEnd);

                var data = wer.GetByDate(WeekEndDate);
                if (data.Count == 0)
                {
                    var prodData = wer.GetAllProducts();
                    foreach (var prod in prodData)
                    {
                        var wkData = new AD_WeekData();
                        wkData.AD_ProductID = prod;
                        wkData.AD_WeekEnd   = WeekEndDate;
                        wer.Save(wkData);
                    }
                    data = wer.GetByDate(WeekEndDate);
                }
                var col = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.AD_Products.AD_GroupID).ToList();

                foreach (var wd in data)
                {
                    var dic = new Dictionary <string, string>();
                    dic.Add("AD_ProductID", wd.AD_ProductID.ToString());
                    dic.Add("ProductName", wd.AD_Products.AD_ProductName);
                    dic.Add("BudgetLbs", wd.AD_BudgetLbs != null ? wd.AD_BudgetLbs.ToString() : "0");
                    dic.Add("BudgetDollars", wd.AD_BudgetDollars != null ? wd.AD_BudgetDollars.ToString() : "0");
                    dic.Add("ActualLbs", wd.AD_ActualLbs != null ? wd.AD_ActualLbs.ToString() : "0");
                    dic.Add("ActualDollars", wd.AD_ActualDollars != null ? wd.AD_ActualDollars.ToString() : "0");
                    dic.Add("AD_WeekDataID", wd.AD_WeekDataID.ToString());
                    col.Add(dic);
                }
                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }



            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #10
0
        public void testToDTO()
        {
            Console.WriteLine("toDTO");
            Authentication auth1 = new Auth("username", "email", "password");
            User           u1    = new User(auth1);
            GenericDTO     dto   = new GenericDTO("User");

            dto.put("1", auth1);
            Assert.True(dto.get("1").Equals(u1.toDTO().get("1")));
        }
 public static void AddResearch(GenericDTO dto)
 {
     var research = new Research();
     research.SetName(dto[NAME_FIELD].ToString());
     research.SetTimeToResearch(ToUlong(dto[TIMETORESEARCH_FIELD]));
     research.SetCostToResearch(ToUlong(dto[COSTTORESEARCH_FIELD]));
     research.SetPrerequisites(ToList(dto[PREREQUISITES_FIELD]));
     string key = dto[KEY_FIELD].ToString();
     _research[key] = research;
 }
Пример #12
0
        public HttpResponseMessage PondO2ByDate([FromBody] O2ReadingDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    UserId    = ur.ValidateUser(uDto.Key, out key, ref companyId);
            //string dayperiod;
            //if (DateTime.Parse(uDto.ReadingDate).Hour < 12)
            //{
            //    dayperiod = DateTime.Parse(uDto.ReadingDate).AddDays(-1).ToShortDateString();
            //}
            //else
            //{
            //    dayperiod = DateTime.Parse(uDto.ReadingDate).ToShortDateString();
            //}
            //uDto.DayPeriod = dayperiod;

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Airtime"))
            {
                var O2r = new O2ReadingRepository();
                var u   = new O2Reading();
                //var predicate = O2r.GetPredicate(uDto, u, companyId);
                var data = O2r.GetPondO2ReadingsByDate(int.Parse(uDto.PondId), DateTime.Parse(uDto.ReadingDate));
                var col  = new Collection <Dictionary <string, string> >();

                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("PondId", item.PondId.ToString());
                    dic.Add("ReadingId", item.ReadingId.ToString());
                    dic.Add("ReadingDate", item.ReadingDate.ToString());
                    dic.Add("O2Level", item.O2Level.ToString());
                    dic.Add("StaticCount", item.StaticCount.ToString());
                    dic.Add("PortableCount", item.PortableCount.ToString());
                    dic.Add("Note", item.Note);
                    dic.Add("PondStatus", item.Pond.HealthStatus.ToString());
                    col.Add(dic);
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #13
0
        public ActionResult List()
        {
            if (sessao.usuarioLogado != null)
            {
                var        jsonPastas = WebService.downloadJson("/Pasta/recuperarPorIdUsuario/" + sessao.usuarioLogado.id.ToString());
                GenericDTO dto        = JsonConvert.DeserializeObject <GenericDTO>(jsonPastas);
                dto.payload         = ((JArray)dto.payload).ToObject <List <Pasta> >();
                ViewBag.json_pastas = PastaJsonConverter.pastaConverter(((List <Pasta>)dto.payload));
            }

            ViewBag.tela = 0;
            return(View());
        }
Пример #14
0
        public HttpResponseMessage PondFeedLast7Days([FromBody] PondDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    UserId    = ur.ValidateUser(uDto.Key, out key, ref companyId);

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Chowtime"))
            {
                var      pr        = new PondRepository();
                var      ponddata  = pr.GetById(int.Parse(uDto.PondId));
                DateTime startdate = DateTime.Now;

                int i   = 0;
                var col = new Collection <Dictionary <string, string> >();
                while (i > -7)
                {
                    var fr   = new FeedingRepository();
                    var data = fr.GetPondFeedingsByDate(ponddata.PondId, startdate.AddDays(i));
                    if (data != null)
                    {
                        var dic = new Dictionary <string, string>();

                        dic.Add("PondId", data.PondId.ToString());
                        dic.Add("FeedingId", data.FeedingId.ToString());
                        dic.Add("FeedDate", data.FeedDate.ToString());
                        dic.Add("PoundsFed", data.PoundsFed.ToString());
                        col.Add(dic);
                    }

                    i--;
                }
                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #15
0
        protected static HttpResponseMessage ProcessValidationErrors(HttpRequestMessage request, List <DbValidationError> validationErrors, string key)
        {
            var col = new Collection <Dictionary <string, string> >();

            foreach (var dic in validationErrors.Select(err => new Dictionary <string, string> {
                { "FieldWithError", err.PropertyName },
                { "Error", err.ErrorMessage }
            }))
            {
                col.Add(dic);
            }
            var retVal = new GenericDTO {
                Key        = key,
                ReturnData = col
            };

            return(request.CreateResponse(HttpStatusCode.BadRequest, retVal));
        }
        internal HttpResponseMessage FarmYieldHeaders(HttpRequestMessage request, FarmYieldHeaderDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new FarmYieldHeaderRepository();
                var u  = new FarmYieldHeader();
                if (cqDTO.YieldDate != null)
                {
                    cqDTO.Start_YieldDate = DateTime.Parse(cqDTO.YieldDate).AddHours(-1).ToString();
                    cqDTO.End_YieldDate   = DateTime.Parse(cqDTO.YieldDate).AddHours(1).ToString();
                }
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.YieldDate).ToList();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();


                    dic.Add("FarmYieldHeaderID", item.FarmYieldHeaderID.ToString());
                    dic.Add("YieldDate", item.YieldDate.ToShortDateString());
                    dic.Add("PlantWeight", item.PlantWeight.ToString());
                    dic.Add("WeighBacks", item.WeighBacks.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #17
0
        //Metodo de criar

        public ActionResult Create()
        {
            //Recuperar Lista de Topicos
            //Recuperar Lista de Tipos

            try
            {
                #region WsTopicos

                String jsonRecebido = WebService.downloadJson("/AtributosNotas/recuperarTopico");

                GenericDTO dtoTopico = JsonConvert.DeserializeObject <GenericDTO>(jsonRecebido);
                dtoTopico.payload = ((JArray)dtoTopico.payload).ToObject <List <Topico> >();

                jsonRecebido = WebService.downloadJson("/AtributosNotas/recuperarTipo");
                GenericDTO dtoTipo = JsonConvert.DeserializeObject <GenericDTO>(jsonRecebido);
                dtoTipo.payload = ((JArray)dtoTipo.payload).ToObject <List <Tipo> >();

                if (dtoTopico.operacaoSucedida && dtoTipo.operacaoSucedida)
                {
                    listaTopico = (List <Topico>)dtoTopico.payload;
                    listaTipo   = (List <Tipo>)dtoTipo.payload;
                }
                else
                {
                    Response.Write(dtoTopico.mensagemErro);
                    return(new EmptyResult());
                }
                #endregion
            }
            catch (Exception e)
            {
                Response.Write("Erro!:" + e.Message);
                return(View());
            }

            ViewBag.ListaTipo   = listaTipo;
            ViewBag.ListaTopico = listaTopico;

            ViewBag.tela = 1;

            return(View());
        }
Пример #18
0
        public List <GenericDTO> GetAllGeneric(GenericDTO generic)
        {
            RepList <GenericDTO> listGenero = new RepList <GenericDTO>();

            string query       = string.Empty;
            string whereClause = " WHERE 1 = 1 ";

            query += "SELECT ";

            switch (generic.dominio)
            {
            case domains.Perfil:
                query += " idGeneric = idPerfil, descGeneric = descPerfil ";
                query += " FROM TB_Perfis A ";
                break;

            case domains.Genero:
                query += " idGeneric = idGenero, descGeneric = descGenero ";
                query += " FROM TB_Generos A ";
                break;

            case domains.TipoPessoa:
                query += " idGeneric = idTipoPessoa, descGeneric = descTipoPessoa ";
                query += " FROM TB_TipoPessoas A ";
                break;

            default:
                break;
            }

            if (generic.flagAtivo == true)
            {
                whereClause += " and A.flagAtivo = 1";
            }
            else if (generic.flagAtivo == false)
            {
                whereClause += " and A.flagAtivo = 0";
            }

            query += whereClause;

            return(listGenero.GetDataInDatabase(query));
        }
Пример #19
0
        public HttpResponseMessage GetLastPondReading([FromBody] O2ReadingDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    UserId    = ur.ValidateUser(uDto.Key, out key, ref companyId);

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Airtime"))
            {
                var O2r = new O2ReadingRepository();
                var u   = new O2Reading();
                //var predicate = O2r.GetPredicate(uDto, u, companyId);
                var data = O2r.GetLastPondReadingByPond(int.Parse(uDto.PondId));
                var col  = new Collection <Dictionary <string, string> >();


                var dic = new Dictionary <string, string>();

                dic.Add("PondId", data.PondId.ToString());
                dic.Add("ReadingId", data.ReadingId.ToString());
                dic.Add("ReadingDate", data.ReadingDate.ToString());
                dic.Add("O2Level", data.O2Level.ToString());
                dic.Add("StaticCount", data.StaticCount.ToString());
                dic.Add("PortableCount", data.PortableCount.ToString());
                dic.Add("Note", data.Note);
                col.Add(dic);



                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #20
0
        internal HttpResponseMessage Users(HttpRequestMessage request, UserDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new UserRepository();
                var u  = new User();
                cqDTO.CompanyId = companyId.ToString();
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();

                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("UserId", item.UserId.ToString());
                    dic.Add("FirstName", item.FirstName);
                    dic.Add("LastName", item.LastName);
                    dic.Add("EmailAddress", item.EmailAddress);
                    dic.Add("Phone", item.Phone);
                    dic.Add("StatusId", item.StatusId.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
        internal HttpResponseMessage TranslatedTerms(HttpRequestMessage request, TranslatedTermDTO cqDTO)
        {
            var ur     = new TranslatedTermRepository();
            var u      = new TranslatedTerm();
            var data   = ur.GetTranslatedTerms(int.Parse(cqDTO.LanguageID));
            var er     = new EnglishTermRepository();
            var eterms = er.GetEnglishTerms();
            var col    = new Collection <Dictionary <string, string> >();

            foreach (var item in eterms)
            {
                var tTerm = data.Where(x => x.EnglishTermID == item.EnglishTermID).FirstOrDefault();
                var dic   = new Dictionary <string, string>();
                dic.Add("EnglishTermID", item.EnglishTermID.ToString());
                dic.Add("LanguageID", cqDTO.LanguageID);
                dic.Add("Term", item.Term.ToString());

                if (tTerm == null)
                {
                    dic.Add("TranslationID", "-1");
                    dic.Add("TermTranslated", "");
                }
                else
                {
                    dic.Add("TranslationID", tTerm.TranslationID.ToString());
                    dic.Add("TermTranslated", tTerm.TermTranslated);
                }

                col.Add(dic);
            }

            var retVal = new GenericDTO
            {
                ReturnData = col
            };

            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
Пример #22
0
        internal HttpResponseMessage EnglishTerms(HttpRequestMessage request, EnglishTermDTO cqDTO)
        {
            var ur   = new EnglishTermRepository();
            var u    = new EnglishTerm();
            var data = ur.GetEnglishTerms();
            var col  = new Collection <Dictionary <string, string> >();

            foreach (var item in data)
            {
                var dic = new Dictionary <string, string>();
                dic.Add("EnglishTermID", item.EnglishTermID.ToString());
                dic.Add("Term", item.Term);
                dic.Add("BeforeOrAfter", item.BeforeOrAfter);
                col.Add(dic);
            }

            var retVal = new GenericDTO
            {
                ReturnData = col
            };

            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
Пример #23
0
        internal HttpResponseMessage Languages(HttpRequestMessage request, LanguageDTO cqDTO)
        {
            var ur   = new LanguageRepository();
            var u    = new Language();
            var data = ur.GetLanguages();
            var col  = new Collection <Dictionary <string, string> >();

            foreach (var item in data)
            {
                var dic = new Dictionary <string, string>();
                dic.Add("LanguageId", item.LanguageID.ToString());
                dic.Add("LanguageName", item.LanguageName);
                dic.Add("CSSFileName", item.CssFileName);
                col.Add(dic);
            }

            var retVal = new GenericDTO
            {
                ReturnData = col
            };

            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
Пример #24
0
        public HttpResponseMessage AllRoles([FromBody] UserDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    userId    = ur.ValidateUser(uDto.Key, out key, ref companyId);

            if (userId > 0)
            {
                var user   = new User();
                var errors = ValidateDtoData(uDto, user);
                if (errors.Any())
                {
                    return(ProcessValidationErrors(Request, errors, key));
                }
                var col  = new Collection <Dictionary <string, string> >();
                var pr   = new RoleRepository();
                var data = pr.GetRoles();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("RoleId", item.RoleId.ToString());
                    dic.Add("RoleName", item.RoleName);
                    col.Add(dic);
                }
                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #25
0
        public HttpResponseMessage MortalityById([FromBody] MortalityDTO uDto)
        {
            string key;
            var    ur                 = new AppUserRepository();
            var    companyId          = 0;
            var    UserId             = ur.ValidateUser(uDto.Key, out key, ref companyId);
            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Chowtime"))
            {
                var O2r  = new AppEntities();
                var data = O2r.Mortalities.Find(int.Parse(uDto.MortalityId));
                var col  = new Collection <Dictionary <string, string> >();


                var dic = new Dictionary <string, string>();

                dic.Add("PondId", data.PondId.ToString());
                dic.Add("MortalityId", data.MortalityId.ToString());
                dic.Add("MortalityDate", data.MortalityDate.ToString());
                dic.Add("MortalityPoundsd", data.MortalityPounds.ToString());
                col.Add(dic);


                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #26
0
        internal HttpResponseMessage DownTimes(HttpRequestMessage request, DownTimeDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new DownTimeRepository();
                var u  = new DownTime();
                if (cqDTO.DownTimeDate != null)
                {
                    cqDTO.Start_DownTimeDate = DateTime.Parse(cqDTO.DownTimeDate).ToString();
                    cqDTO.End_DownTimeDate   = DateTime.Parse(cqDTO.DownTimeDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_DownTimeDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_DownTimeDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_DownTimeDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_DownTimeDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_DownTimeDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_DownTimeDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }


                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.DownTimeDate).ToList();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("DownTimeID", item.DownTimeID.ToString());
                    dic.Add("DepartmentID", item.DownTimeType.DepartmentID.ToString());
                    dic.Add("DepartmentName", item.DownTimeType.Department.DepartmentName);
                    dic.Add("DownTimeDate", item.DownTimeDate.ToShortDateString());
                    dic.Add("DownTimeTypeID", item.DownTimeTypeID.ToString());
                    dic.Add("DownTimeType", item.DownTimeType.DownTimeName.ToString());
                    dic.Add("Minutes", item.Minutes.ToString());
                    dic.Add("Note", item.DownTimeNote.ToString());

                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }
                var dttr = new DownTimeTypeRepository();
                var dtts = dttr.GetDownTimeTypesByDept(int.Parse(cqDTO.DepartmentID));
                var col2 = new Collection <Dictionary <string, string> >();
                foreach (var dtt in dtts)
                {
                    var dic = new Dictionary <string, string>();
                    dic.Add("DownTimeTypeID", dtt.DownTimeTypeID.ToString());
                    dic.Add("DownTypeName", dtt.DownTimeName);
                    col2.Add(dic);
                }

                var retVal = new GenericDTO
                {
                    Key         = key,
                    ReturnData  = col,
                    ReturnData1 = col2
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
        internal HttpResponseMessage Emails(HttpRequestMessage request, EmailDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new EmailRepository();
                var u  = new Email();

                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.EmailAddress).ToList();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();


                    dic.Add("EmailID", item.EmailID.ToString());
                    dic.Add("EmailAddress", item.EmailAddress);
                    dic.Add("ReceiveDailyReport", item.ReceiveDailyReport.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var ur2 = new EmailListRepository();
                var u2  = new EmailList();

                var predicate2 = ur2.GetPredicate(cqDTO, u2, companyId);
                var data2      = ur2.GetByPredicate(predicate);
                var col2       = new Collection <Dictionary <string, string> >();
                data2 = data2.OrderBy(x => x.EmailListName).ToList();
                foreach (var item in data2)
                {
                    var dic = new Dictionary <string, string>();


                    dic.Add("EmailListId", item.EmailListId.ToString());
                    dic.Add("EmailListName", item.EmailListName);
                    col2.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                //var ur3 = new ListEmailRepository();
                //var u3 = new ListEmail();

                //var predicate3 = ur3.GetPredicate(cqDTO, u3, companyId);
                //var data3 = ur3.GetByPredicate(predicate);
                //var col3 = new Collection<Dictionary<string, string>>();
                //data3 = data3.ToList();
                //foreach (var item in data3)
                //{

                //    var dic = new Dictionary<string, string>();


                //    dic.Add("ListId", item.ListId.ToString());
                //    dic.Add("EmailId", item.EmailId.ToString());
                //    col3.Add(dic);
                //    var ufdic = new Dictionary<string, string>();


                //}

                var retValList = new List <GenericDTO>();
                var retVal     = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                retValList.Add(retVal);
                var retVal2 = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col2
                };
                retValList.Add(retVal2);

                //var retVal3 = new GenericDTO
                //{
                //    Key = key,
                //    ReturnData = col3
                //};
                //retValList.Add(retVal3);

                return(Request.CreateResponse(HttpStatusCode.OK, retValList));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #28
0
        public HttpResponseMessage ProductionTotals([FromBody] ProductionTotalDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new ProductionTotalRepository();
                var u  = new ProductionTotal();
                if (cqDTO.ProductionDate != null)
                {
                    cqDTO.Start_ProductionDate = DateTime.Parse(cqDTO.ProductionDate).ToString();
                    cqDTO.End_ProductionDate   = DateTime.Parse(cqDTO.ProductionDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }
                SGApp.DTOs.GenericDTO dto = new GenericDTO();
                dto.StartDate = DateTime.Parse(cqDTO.Start_ProductionDate);
                dto.EndDate   = DateTime.Parse(cqDTO.End_ProductionDate);
                List <DTOs.Sampling> samplingResults = new List <DTOs.Sampling>();
                PondRepository       pr = new PondRepository();
                var client = new HttpClient
                {
                    //BaseAddress = new Uri("http://323-booth-svr2:3030/")
                    BaseAddress = new Uri("http://64.139.95.243:7846/")
                                  //BaseAddress = new Uri(baseAddress)
                };
                try
                {
                    var response = client.PostAsJsonAsync("api/Remote/GetKeithsData", dto).Result;
                    response.EnsureSuccessStatusCode();
                    JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                    //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(response.Content.ReadAsStringAsync().Result); // new List<Sampling>();
                    //Sampling[] samplingResultsArray = response.Content.ReadAsAsync<Sampling[]>().Result;
                    //samplingResults = samplingResultsArray.ToList();
                    //JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                    //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(Constants.testdata);
                    DTOs.Sampling[] samplingResultsArray = json_serializer.Deserialize <DTOs.Sampling[]>(response.Content.ReadAsStringAsync().Result);
                    samplingResults = samplingResultsArray.ToList();
                    samplingResults = samplingResults.GroupBy(x => x.farmPond).Select(group => group.First()).ToList();
                    //var result = response.Content.ReadAsStringAsync().Result;

                    //return Request.CreateResponse(HttpStatusCode.OK, result);
                }
                catch (Exception e)
                {
                    throw new HttpException("Error occurred: " + e.Message);
                }
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.ProductionDate).ToList();

                foreach (DTOs.Sampling sam in samplingResults)
                {
                    ProductionTotal fy  = data.Where(x => x.Pond.InnovaName == sam.farmPond).FirstOrDefault();
                    Pond            pd  = pr.GetPondFromInnovaName(sam.farmPond);
                    var             dic = new Dictionary <string, string>();
                    if (fy != null)
                    {
                        var wb = fy.WeighBacks != null ? fy.WeighBacks : 0;
                        dic.Add("ProductionTotalId", fy.ProductionTotalID.ToString());
                        dic.Add("PondID", fy.PondId.ToString());
                        dic.Add("PondName", sam.farmPond);
                        dic.Add("FarmID", fy.Pond.FarmId.ToString());
                        dic.Add("ProductionDate", fy.ProductionDate.ToShortDateString());
                        dic.Add("PlantWeight", fy.PlantWeight != null ? fy.PlantWeight.ToString() : "---");
                        dic.Add("PondWeight", fy.PondWeight != null ? fy.PondWeight.ToString() : "---");
                        dic.Add("WeighBacks", fy.WeighBacks != null ? fy.WeighBacks.ToString() : "---");
                        dic.Add("AverageYield", fy.AverageYield != null ? fy.AverageYield.ToString() : "---");
                        dic.Add("HeadedWeight", fy.AverageYield != null && fy.PlantWeight != null ? String.Format("{0:0.00}", ((fy.AverageYield / 100) * (fy.PlantWeight - wb))) : "---");
                    }
                    else
                    {
                        dic.Add("ProductionTotalId", "-1");
                        dic.Add("PondID", pd.PondId.ToString() != null ? pd.PondId.ToString() : "");
                        dic.Add("PondName", sam.farmPond != null ? sam.farmPond : "");
                        dic.Add("FarmID", pd.FarmId.ToString() != null ? pd.FarmId.ToString() : "");
                        dic.Add("ProductionDate", cqDTO.ProductionDate);
                        dic.Add("PlantWeight", "---");
                        dic.Add("PondWeight", "---");
                        dic.Add("WeighBacks", "---");
                        dic.Add("AverageYield", "---");
                        dic.Add("HeadedWeight", "---");
                    }

                    col.Add(dic);
                }
                //foreach (FarmYield fy in data)
                //{

                //    Sampling samp = samplingResults.Where(x => x.farmPond == fy.Pond.InnovaName).FirstOrDefault();
                //    var dic = new Dictionary<string, string>();
                //    if (samp == null)
                //    {
                //        dic.Add("YieldId", fy.YieldID.ToString());
                //        dic.Add("PondID", fy.PondID.ToString());
                //        dic.Add("PondName", fy.Pond.InnovaName != null ? fy.Pond.InnovaName : fy.Pond.PondName);
                //        dic.Add("FarmID", fy.Pond.FarmId.ToString());
                //        dic.Add("YieldDate", fy.YieldDate.ToShortDateString());
                //        dic.Add("PoundsYielded", fy.PoundsYielded.ToString());
                //        dic.Add("PoundsPlant", fy.PoundsPlant.ToString());
                //        dic.Add("PoundsHeaded", fy.PoundsHeaded.ToString());
                //        dic.Add("PercentYield", fy.PercentYield.ToString());
                //        dic.Add("PercentYield2", fy.PercentYield2.ToString());
                //        col.Add(dic);
                //    }


                //}

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
        internal HttpResponseMessage Absences(HttpRequestMessage request, AbsenceDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new AbsenceRepository();
                var u  = new Absence();
                if (cqDTO.AbsenceDate != null)
                {
                    cqDTO.Start_AbsenceDate = DateTime.Parse(cqDTO.AbsenceDate).ToString();
                    cqDTO.End_AbsenceDate   = DateTime.Parse(cqDTO.AbsenceDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_AbsenceDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_AbsenceDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_AbsenceDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_AbsenceDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_AbsenceDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_AbsenceDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }

                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.AbsenceDate).ToList();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("AbsenceID", item.AbsenceID.ToString());
                    dic.Add("DepartmentID", item.DepartmentID.ToString());
                    dic.Add("DepartmentName", item.Department.DepartmentName);
                    dic.Add("AbsenceDate", item.AbsenceDate.ToShortDateString());
                    dic.Add("RegEmpLate", item.RegEmpLate.ToString());
                    dic.Add("RegEmpLeftEarly", item.RegEmpLeftEarly.ToString());
                    dic.Add("RegEmpOut", item.RegEmpOut.ToString());
                    dic.Add("TempEmpLate", item.TempEmpLate.ToString());
                    dic.Add("TempEmpLeftEarly", item.TempEmpLeftEarly.ToString());
                    dic.Add("TempEmpOut", item.TempEmpOut.ToString());
                    dic.Add("InmateLeftEarly", item.InmateLeftEarly.ToString());
                    dic.Add("InmateOut", item.InmateOut.ToString());
                    dic.Add("EmployeesOnVacation", item.EmployeesOnVacation.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Пример #30
0
        public List <GenericDTO> GetAllData(GenericDTO generic)
        {
            GenericDAL cmd = new GenericDAL();

            return(cmd.GetAllGeneric(generic));
        }
 public static void AddTechnology(GenericDTO dto)
 {
 }
        internal HttpResponseMessage FarmYields(HttpRequestMessage request, FarmYieldDTO cqDTO)
        {
            string key;
            var    aur       = new AppUserRepository();
            var    companyId = 0;
            var    userId    = aur.ValidateUser(cqDTO.Key, out key, ref companyId);

            if (userId > 0)
            {
                var ur = new FarmYieldRepository();
                var u  = new FarmYield();
                if (cqDTO.YieldDate != null)
                {
                    cqDTO.Start_YieldDate = DateTime.Parse(cqDTO.YieldDate).ToString();
                    cqDTO.End_YieldDate   = DateTime.Parse(cqDTO.YieldDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_YieldDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_YieldDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_YieldDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_YieldDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_YieldDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_YieldDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }

                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.YieldDate).ToList();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();

                    dic.Add("YieldId", item.YieldID.ToString());
                    dic.Add("PondID", item.PondID.ToString());
                    dic.Add("PondName", item.Pond.PondName);
                    dic.Add("FarmID", item.Pond.FarmId.ToString());
                    dic.Add("YieldDate", item.YieldDate.ToShortDateString());
                    dic.Add("PoundsYielded", item.PoundsYielded.ToString());
                    dic.Add("PoundsPlant", item.PoundsPlant.ToString());
                    dic.Add("PoundsHeaded", item.PoundsHeaded.ToString());
                    dic.Add("PercentYield", item.PercentYield.ToString());
                    dic.Add("PercentYield2", item.PercentYield2.ToString());
                    col.Add(dic);
                    var ufdic = new Dictionary <string, string>();
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }