Ejemplo n.º 1
0
 public void Logout([FromBody] BaseModel post)
 {
     try
     {
         if (post.guid != null)
         {
             DAOCRM.LogoutUser(post.guid);
         }
     }
     catch (Exception ex)
     {
         SaveErrorDB.AddError(ex, new StackTrace().GetFrame(0).GetMethod().Name, MethodBase.GetCurrentMethod().DeclaringType?.FullName);
     }
 }
Ejemplo n.º 2
0
        public UserModel Login([FromBody] LoginDataModel post)
        {
            try
            {
                DataTable dt = new DataTable();

                if (post.guid != null)
                {
                    dt = DAOCRM.LoginedUser(post.guid);
                }
                else
                {
                    post.guid = Guid.NewGuid().ToString();
                    dt        = DAOCRM.LoginUser(post.login, post.password, post.guid);
                }

                if (dt == null)
                {
                    return new UserModel {
                               error = "Incorrect login or password"
                    }
                }
                ;
                if (dt.Rows.Count < 1)
                {
                    return new UserModel {
                               error = "Incorrect login or password"
                    }
                }
                ;

                return(new UserModel
                {
                    guid = post.guid,
                    id = Convert.ToInt32(dt.Rows[0]["USR_Id"].ToString()),
                    type = Convert.ToInt32(dt.Rows[0]["USR_Type"].ToString()),
                    login = dt.Rows[0]["USR_Login"].ToString(),
                    mail = dt.Rows[0]["USR_Mail"].ToString(),
                    name = dt.Rows[0]["USR_Name"].ToString()
                });
            }
            catch (Exception ex)
            {
                SaveErrorDB.AddError(ex, new StackTrace().GetFrame(0).GetMethod().Name, MethodBase.GetCurrentMethod().DeclaringType?.FullName);
                return(new UserModel {
                    error = ex.Message
                });
            }
        }
Ejemplo n.º 3
0
        public TaskModel AddTask([FromBody] TaskModel post)
        {
            try
            {
                if (post.guid == null)
                {
                    return new TaskModel {
                               error = "User is not logined"
                    }
                }
                ;

                DataTable dt = DAOCRM.AddTask(post.guid, post.usrRealize, post.title, post.content, post.description);

                if (dt == null)
                {
                    return new TaskModel {
                               error = "Application is not added"
                    }
                }
                ;
                if (dt.Rows.Count < 1)
                {
                    return new TaskModel {
                               error = "Application is not added"
                    }
                }
                ;

                return(new TaskModel
                {
                    nid = Convert.ToInt32(dt.Rows[0]["Tsk_Id"].ToString()),
                    sid = dt.Rows[0]["Tsk_Number"].ToString()
                });
            }
            catch (Exception ex)
            {
                SaveErrorDB.AddError(ex, new StackTrace().GetFrame(0).GetMethod().Name, MethodBase.GetCurrentMethod().DeclaringType?.FullName);
                return(new TaskModel {
                    error = ex.Message
                });
            }
        }
Ejemplo n.º 4
0
        public List <TaskModel> GetClientTasks([FromBody] TaskModel post)
        {
            List <TaskModel> result = new List <TaskModel>();

            try
            {
                if (post.guid == null)
                {
                    result.Add(new TaskModel {
                        error = "User is not logined"
                    });

                    return(result);
                }

                DataTable applications = DAOCRM.ClientTasksList(post.guid);
                if (applications == null)
                {
                    result.Add(new TaskModel {
                        error = "Error get applications list"
                    });
                    return(result);
                }

                if (applications.Rows.Count < 1)
                {
                    return(result);
                }

                foreach (DataRow application in applications.Rows)
                {
                    TaskModel temp = new TaskModel
                    {
                        nid            = Convert.ToInt32(application["Tsk_Id"].ToString()),
                        sid            = application["Tsk_Number"].ToString(),
                        ntype          = Convert.ToInt32(application["Tsk_Type"].ToString()),
                        stype          = application["Tsk_SType"].ToString(),
                        nstate         = Convert.ToInt32(application["Tsk_State"].ToString()),
                        sstate         = application["Tsk_SState"].ToString(),
                        usrCreate      = Convert.ToInt32(application["Tsk_UsrCreate"].ToString()),
                        usrCreateName  = application["usrCreateName"].ToString(),
                        usrRealize     = Convert.ToInt32(application["Tsk_UsrRealize"].ToString()),
                        usrRealizeName = application["usrRealizeName"].ToString(),
                        title          = application["Tsk_Title"].ToString(),
                        content        = application["Tsk_Content"].ToString(),
                        description    = application["Tsk_Description"].ToString(),
                        dateCreate     = application["Tsk_DateCreate"].ToString() != "" ? Convert.ToDateTime(application["Tsk_DateCreate"].ToString()) : (DateTime?)null,
                        dateRealize    = application["Tsk_DateRealize"].ToString() != "" ? Convert.ToDateTime(application["Tsk_DateRealize"].ToString()): (DateTime?)null
                    };

                    result.Add(temp);
                }

                return(result);
            }
            catch (Exception ex)
            {
                SaveErrorDB.AddError(ex, new StackTrace().GetFrame(0).GetMethod().Name, MethodBase.GetCurrentMethod().DeclaringType?.FullName);
                TaskModel error = new TaskModel {
                    error = ex.Message
                };
                result.Add(error);
                return(result);
            }
        }