Ejemplo n.º 1
0
        //CREA LA ACTIVIDAD QUE EL USUARIO ESTA REALIZANDO
        public object CreateAutomaticTakeTime(TrackerModel o)
        {
            Response rp = new Response();

            try
            {
                cp = tvh.getprincipal(Convert.ToString(o.token));
                if (cp != null)
                {
                    string            empresa = cp.Claims.Where(c => c.Type == ClaimTypes.GroupSid).Select(c => c.Value).SingleOrDefault();
                    List <TrakerBase> ltb     = new List <TrakerBase>();

                    foreach (var i in o.AutomaticTakeTimeModel)
                    {
                        TrakerBase tb = new TrakerBase();
                        i.IdEmpresa = empresa;
                        Copier.CopyPropertiesTo(i, tb);
                        ltb.Add(tb);
                    }

                    if (ltb.Count() > 0)
                    {
                        bool response = opc.AddTracker(ltb);
                        if (response)
                        {
                            rp.response_code = GenericErrors.SaveOk.ToString();
                        }
                        else
                        {
                            rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.GeneralError, string.Empty, null, HttpStatusCode.InternalServerError);
                        }
                    }
                }
                else
                {
                    //token invalido
                    rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.InvalidToken, string.Empty, null, HttpStatusCode.OK);
                    return(rp);
                }

                return(rp);
            }
            catch (Exception ex)
            {
                //error general
                rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.GeneralError, ex.Message + " " + ex.InnerException, null, HttpStatusCode.InternalServerError);
                return(rp);
            }
        }