예제 #1
0
        //public bool Delete(int id)
        //{
        //    var result = new Result<SavedFile>();
        //    try
        //    {
        //        string query = "delete from SavedFile where SavedFileId=" + id;
        //        return DataAccess.ExecuteQuery(query) > 0;
        //    }
        //    catch (Exception ex)
        //    {
        //        return false;
        //    }
        //}

        private bool IsValid(SavedFile obj, Result <SavedFile> result)
        {
            if (!ValidationHelper.IsStringValid(obj.FileLink))
            {
                result.HasError = true;
                result.Message  = "Invalid School Name";
                return(false);
            }



            return(true);
        }
예제 #2
0
        private SavedFile ConvertToEntity(DataRow row)
        {
            try
            {
                SavedFile u = new SavedFile();
                u.SavedFileId      = Int32.Parse(row["CommunicationId"].ToString());
                u.UserId           = Int32.Parse(row["UserID"].ToString());
                u.ProjectSectionId = Int32.Parse(row["ProjectSectionId"].ToString());
                u.FileLink         = row["comment"].ToString();



                return(u);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #3
0
        public Result <SavedFile> Save(SavedFile SavedFile)
        {
            var result = new Result <SavedFile>();

            try
            {
                string query = "select * from SavedFile where SavedFileId=" + SavedFile.SavedFileId;
                var    dt    = DataAccess.GetDataTable(query);

                if (dt == null || dt.Rows.Count == 0)
                {
                    SavedFile.SavedFileId = GetID();
                    query = "insert into SavedFile values(" + SavedFile.SavedFileId + "," + SavedFile.ProjectSection + "," + SavedFile.UserId + ",'" + SavedFile.FileLink + "')";
                }
                //else
                //{
                //    query = "update SavedFile set ProjectName='" + SavedFile.ProjectName + "',StartTime='" + SavedFile.StartTime + "',EndTime='" + SavedFile.EndTime + "',Description='" + SavedFile.Description + "',ProjectSection='" + SavedFile.ProjectSection + "',Price=" + SavedFile.Price + ",Members=" + SavedFile.Members + " where PostID=" + SavedFile.PostId;
                //}

                if (!IsValid(SavedFile, result))
                {
                    return(result);
                }

                result.HasError = DataAccess.ExecuteQuery(query) <= 0;

                if (result.HasError)
                {
                    result.Message = "Something Went Wrong";
                }
                else
                {
                    result.Data = SavedFile;
                }
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }
예제 #4
0
        public List <SavedFile> GetAll()
        {
            var result = new List <SavedFile>();

            try
            {
                string query = "select * from SavedFile";
                var    dt    = DataAccess.GetDataTable(query);

                if (dt != null && dt.Rows.Count != 0)
                {
                    for (int i = 0; i <= dt.Rows.Count; i++)
                    {
                        SavedFile u = ConvertToEntity(dt.Rows[i]);
                        result.Add(u);
                    }
                }
            }
            catch (Exception ex)
            {
                return(result);
            }
            return(result);
        }